|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface List<ELTTYPE>
Interface describing lists. Lists are collections of data with a head and tail. Values may be added or removed from either end, as well as by value from the middle. The structure package provides several implementations of the List interface, each of which has its particular strengths and weaknesses.
Example usage:
To place a copy of every unique parameter passed to a program into a List, we could use the following:
public static void main(String[]
arguments) {List
argList = newSinglyLinkedList()
; for (int i = 0; i < arguments.length; i++){ if (!argList.contains(arguments[i])
){ argList.add(arguments[i])
; } } System.out.println(argList); }
SinglyLinkedList
,
DoublyLinkedList
,
CircularList
Method Summary | |
---|---|
void |
add(ELTTYPE value)
Add an object to tail of list. |
void |
add(int i,
ELTTYPE o)
Insert value at location. |
void |
addFirst(ELTTYPE value)
Add a value to the head of the list. |
void |
addLast(ELTTYPE value)
Add a value to tail of list. |
void |
clear()
Remove all elements of list. |
boolean |
contains(ELTTYPE value)
Check to see if a value is in list. |
ELTTYPE |
get()
Retrieves value from tail of list. |
ELTTYPE |
get(int i)
Get value at location i. |
ELTTYPE |
getFirst()
Fetch first element of list. |
ELTTYPE |
getLast()
Fetch last element of list. |
int |
indexOf(ELTTYPE value)
Determine first location of a value in list. |
boolean |
isEmpty()
Determine if list is empty. |
java.util.Iterator<ELTTYPE> |
iterator()
Construct an iterator to traverse elements of list from head to tail, in order. |
int |
lastIndexOf(ELTTYPE value)
Determine last location of a value in list. |
ELTTYPE |
remove()
Removes value from tail of list. |
ELTTYPE |
remove(ELTTYPE value)
Remove a value from list. |
ELTTYPE |
remove(int i)
Remove and return value at location i. |
ELTTYPE |
removeFirst()
Remove a value from first element of list. |
ELTTYPE |
removeLast()
Remove last value from 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. |
Methods inherited from interface structure.Structure |
---|
elements, values |
Method Detail |
---|
int size()
size
in interface Structure<ELTTYPE>
boolean isEmpty()
isEmpty
in interface Structure<ELTTYPE>
void clear()
clear
in interface Structure<ELTTYPE>
void addFirst(ELTTYPE value)
value
- The value to be added to the head of the list.void addLast(ELTTYPE value)
value
- The value to be added to tail of list.ELTTYPE getFirst()
ELTTYPE getLast()
ELTTYPE removeFirst()
ELTTYPE removeLast()
ELTTYPE remove(ELTTYPE value)
remove
in interface Structure<ELTTYPE>
value
- The value to be removed.
void add(ELTTYPE value)
add
in interface Structure<ELTTYPE>
value
- The value to be added to tail of list.addLast(ELTTYPE)
ELTTYPE remove()
ELTTYPE get()
boolean contains(ELTTYPE value)
contains
in interface Structure<ELTTYPE>
value
- value sought.
int indexOf(ELTTYPE value)
value
- The value sought.
int lastIndexOf(ELTTYPE value)
value
- value sought.
ELTTYPE get(int i)
i
- position of value to be retrieved.
ELTTYPE set(int i, ELTTYPE o)
i
- location of entry to be changed.o
- new value
void add(int i, ELTTYPE o)
i
- index of this new valueo
- value to be storedELTTYPE remove(int i)
i
- position of value to be retrieved.
java.util.Iterator<ELTTYPE> iterator()
iterator
in interface java.lang.Iterable<ELTTYPE>
iterator
in interface Structure<ELTTYPE>
AbstractIterator
,
Iterator
,
Enumeration
,
Structure.elements()
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |