|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object structure.AbstractStructure structure.AbstractList structure.DoublyLinkedList
public class DoublyLinkedList
An implementation of lists that makes use of doubly linked elements. This provided efficient implementation of both head and tail operations.
Field Summary | |
---|---|
protected int |
count
Number of elements within list. |
protected DoublyLinkedNode |
head
Reference to head of list. |
protected DoublyLinkedNode |
tail
Reference to tail of list. |
Constructor Summary | |
---|---|
DoublyLinkedList()
Constructs an empty list. |
Method Summary | |
---|---|
void |
add(int i,
java.lang.Object o)
Insert value at location. |
void |
add(java.lang.Object value)
Add a value to head of list. |
void |
addFirst(java.lang.Object value)
Add a value to head of list. |
void |
addLast(java.lang.Object value)
Add a value to tail of list. |
void |
clear()
Remove all values from list. |
boolean |
contains(java.lang.Object value)
Check to see if a value is within list. |
java.lang.Object |
get(int i)
Get value at location i. |
java.lang.Object |
getFirst()
Get a copy of first value found in list. |
java.lang.Object |
getLast()
Get a copy of last value found in list. |
int |
indexOf(java.lang.Object value)
Determine first location of a value in list. |
boolean |
isEmpty()
Determine if list is empty. |
java.util.Iterator |
iterator()
Construct an iterator to traverse list. |
int |
lastIndexOf(java.lang.Object value)
Determine last location of a value in list. |
java.lang.Object |
remove(int i)
Remove and return value at location i. |
java.lang.Object |
remove(java.lang.Object value)
Remove a value from list. |
java.lang.Object |
removeFirst()
Remove a value from head of list. |
java.lang.Object |
removeLast()
Remove a value from tail of list. |
java.lang.Object |
set(int i,
java.lang.Object o)
Set value stored at location i to object o, returning old value. |
int |
size()
Determine number of elements in list. |
java.lang.String |
toString()
Construct 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 |
---|
clone, equals, finalize, getClass, notify, notifyAll, wait, wait, wait |
Methods inherited from interface structure.Structure |
---|
elements, values |
Field Detail |
---|
protected int count
protected DoublyLinkedNode head
protected DoublyLinkedNode tail
Constructor Detail |
---|
public DoublyLinkedList()
Method Detail |
---|
public void add(java.lang.Object value)
add
in interface List
add
in interface Structure
add
in class AbstractList
value
- value to be added.#addToHead
public void addFirst(java.lang.Object value)
addFirst
in interface List
addFirst
in class AbstractList
value
- value to be added.public java.lang.Object removeFirst()
removeFirst
in interface List
removeFirst
in class AbstractList
public void addLast(java.lang.Object value)
addLast
in interface List
addLast
in class AbstractList
value
- value to be added.public java.lang.Object removeLast()
removeLast
in interface List
removeLast
in class AbstractList
public java.lang.Object getFirst()
getFirst
in interface List
getFirst
in class AbstractList
public java.lang.Object getLast()
getLast
in interface List
getLast
in class AbstractList
public boolean contains(java.lang.Object value)
contains
in interface List
contains
in interface Structure
contains
in class AbstractList
value
- A value to be found in list.
public java.lang.Object remove(java.lang.Object value)
value
- value to be removed.
public int size()
public boolean isEmpty()
isEmpty
in interface List
isEmpty
in interface Structure
isEmpty
in class AbstractList
public void clear()
public java.lang.Object get(int i)
i
- position of value to be retrieved.
public java.lang.Object set(int i, java.lang.Object o)
i
- location of entry to be changed.o
- new value
public void add(int i, java.lang.Object o)
i
- index of this new valueo
- value to be storedpublic java.lang.Object remove(int i)
i
- position of value to be retrieved.
public int indexOf(java.lang.Object value)
value
- value sought.
public int lastIndexOf(java.lang.Object value)
value
- value sought.
public java.util.Iterator iterator()
AbstractIterator
,
Iterator
,
Enumeration
,
Structure.elements()
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 |