|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||
java.lang.Objectstructure.AbstractStructure<ELTTYPE>
structure.AbstractList<ELTTYPE>
structure.CircularList<ELTTYPE>
public class CircularList<ELTTYPE>
An implementation of lists using circularly linked elements,
similar to that of java.util.LinkedList.
This class is an implementation of the List interface.
Operations accessing or modifying either the head or the tail of
the list execute in constant time.
Circular lists are as space-efficient as singly linked lists,
but tail-related operations are less costly.
Example usage: To place a copy of every unique parameter passed to a program into a CircularList, we would use the following:
public static void main(String[]arguments) {CircularListargList = newCircularList(); for (int i = 0; i < arguments.length; i++){ if (!argList.contains(arguments[i])){ argList.add(arguments[i]); } } System.out.println(argList); }
SinglyLinkedList,
DoublyLinkedList| Constructor Summary | |
|---|---|
CircularList()
Construct an empty circular list. |
|
| Method Summary | |
|---|---|
void |
add(ELTTYPE value)
Add an element to head of circular list. |
void |
add(int i,
ELTTYPE o)
Insert value at location. |
void |
addFirst(ELTTYPE value)
Add an element to head of list. |
void |
addLast(ELTTYPE value)
Add a value to tail of circular list. |
void |
clear()
Remove elements of list. |
boolean |
contains(ELTTYPE value)
Check if a list contains an element. |
ELTTYPE |
get(int i)
Get value at location i. |
ELTTYPE |
getFirst()
Determine if a list is empty. |
ELTTYPE |
getLast()
Peek at last element of list. |
int |
indexOf(ELTTYPE value)
Determine first location of a value in list. |
boolean |
isEmpty()
Determine if a list is empty. |
java.util.Iterator<ELTTYPE> |
iterator()
Construct an iterator over elements of list. |
int |
lastIndexOf(ELTTYPE value)
Determine last location of a value in list. |
ELTTYPE |
remove(ELTTYPE value)
Remove a value from a list. |
ELTTYPE |
remove(int i)
Remove and return value at location i. |
ELTTYPE |
removeFirst()
Remove a value from head of list. |
ELTTYPE |
removeLast()
Remove a value from tail of list. |
ELTTYPE |
set(int i,
ELTTYPE o)
Set value stored at location i to object o, returning old value. |
int |
size()
Determine size of list. |
java.lang.String |
toString()
Generate a string representation of list. |
| Methods inherited from class structure.AbstractList |
|---|
get, remove |
| Methods inherited from class structure.AbstractStructure |
|---|
elements, hashCode, values |
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, notify, notifyAll, wait, wait, wait |
| Methods inherited from interface structure.Structure |
|---|
elements, values |
| Constructor Detail |
|---|
public CircularList()
| Method Detail |
|---|
public void add(ELTTYPE value)
add in interface List<ELTTYPE>add in interface Structure<ELTTYPE>add in class AbstractList<ELTTYPE>value - value to be added to list.AbstractList.addLast(ELTTYPE)public void addFirst(ELTTYPE value)
addFirst in interface List<ELTTYPE>addFirst in class AbstractList<ELTTYPE>value - value added to head of list.public void addLast(ELTTYPE value)
addLast in interface List<ELTTYPE>addLast in class AbstractList<ELTTYPE>value - value to be added.public ELTTYPE getFirst()
getFirst in interface List<ELTTYPE>getFirst in class AbstractList<ELTTYPE>public ELTTYPE getLast()
getLast in interface List<ELTTYPE>getLast in class AbstractList<ELTTYPE>public ELTTYPE removeFirst()
removeFirst in interface List<ELTTYPE>removeFirst in class AbstractList<ELTTYPE>public ELTTYPE removeLast()
removeLast in interface List<ELTTYPE>removeLast in class AbstractList<ELTTYPE>public boolean contains(ELTTYPE value)
contains in interface List<ELTTYPE>contains in interface Structure<ELTTYPE>contains in class AbstractList<ELTTYPE>value - value sought.
public ELTTYPE remove(ELTTYPE value)
value - value sought.
public int size()
public ELTTYPE get(int i)
i - position of value to be retrieved.
public ELTTYPE set(int i,
ELTTYPE o)
i - location of entry to be changed.o - new value
public void add(int i,
ELTTYPE o)
i - index of this new valueo - value to be storedpublic ELTTYPE remove(int i)
i - position of value to be retrieved.
public int indexOf(ELTTYPE value)
value - value sought.
public int lastIndexOf(ELTTYPE value)
value - value sought.
public java.util.Iterator<ELTTYPE> iterator()
AbstractIterator,
Iterator,
Enumeration,
Structure.elements()public boolean isEmpty()
isEmpty in interface List<ELTTYPE>isEmpty in interface Structure<ELTTYPE>isEmpty in class AbstractList<ELTTYPE>public void clear()
public java.lang.String toString()
toString in class java.lang.Object
|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||