|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface List<E>
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(E value)
Add an object to tail of list. |
void |
add(int i,
E o)
Insert value at location. |
void |
addFirst(E value)
Add a value to the head of the list. |
void |
addLast(E value)
Add a value to tail of list. |
void |
clear()
Remove all elements of list. |
boolean |
contains(E value)
Check to see if a value is in list. |
E |
get()
Retrieves value from tail of list. |
E |
get(int i)
Get value at location i. |
E |
getFirst()
Fetch first element of list. |
E |
getLast()
Fetch last element of list. |
int |
indexOf(E value)
Determine first location of a value in list. |
boolean |
isEmpty()
Determine if list is empty. |
Iterator<E> |
iterator()
Construct an iterator to traverse elements of list from head to tail, in order. |
int |
lastIndexOf(E value)
Determine last location of a value in list. |
E |
remove()
Removes value from tail of list. |
E |
remove(E value)
Remove a value from list. |
E |
remove(int i)
Remove and return value at location i. |
E |
removeFirst()
Remove a value from first element of list. |
E |
removeLast()
Remove last value from list. |
E |
set(int i,
E o)
Set value stored at location i to object o, returning old value. |
int |
size()
Determine size of list. |
Methods inherited from interface structure5.Structure |
---|
elements, values |
Method Detail |
---|
int size()
size
in interface Structure<E>
boolean isEmpty()
isEmpty
in interface Structure<E>
void clear()
clear
in interface Structure<E>
void addFirst(E value)
value
- The value to be added to the head of the list.void addLast(E value)
value
- The value to be added to tail of list.E getFirst()
E getLast()
E removeFirst()
E removeLast()
E remove(E value)
remove
in interface Structure<E>
value
- The value to be removed.
void add(E value)
add
in interface Structure<E>
value
- The value to be added to tail of list.addLast(E)
E remove()
E get()
boolean contains(E value)
contains
in interface Structure<E>
value
- value sought.
int indexOf(E value)
value
- The value sought.
int lastIndexOf(E value)
value
- value sought.
E get(int i)
i
- position of value to be retrieved.
E set(int i, E o)
i
- location of entry to be changed.o
- new value
void add(int i, E o)
i
- index of this new valueo
- value to be storedE remove(int i)
i
- position of value to be retrieved.
Iterator<E> iterator()
iterator
in interface Iterable<E>
iterator
in interface Structure<E>
AbstractIterator
,
Iterator
,
Enumeration
,
Structure.elements()
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |