|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object structure.AbstractStructure structure.AbstractList structure.SinglyLinkedList
public class SinglyLinkedList
Singly linked lists have elements connected by a single reference. They are space-efficient, but tail-related operations may be more costly than with doubly linked lists.
DoublyLinkedList
Constructor Summary | |
---|---|
SinglyLinkedList()
Construct an empty list. |
Method Summary | |
---|---|
void |
add(int i,
Object o)
Insert value at location. |
void |
add(Object value)
Add an object to tail of list. |
void |
addFirst(Object value)
Add a value to head of list. |
void |
addLast(Object value)
Add a value to tail of list. |
void |
clear()
Remove all values from list. |
boolean |
contains(Object value)
Check to see if a value is in list. |
Object |
get(int i)
Get value at location i. |
Object |
getFirst()
Fetch first element of list. |
Object |
getLast()
Fetch last element of list. |
int |
indexOf(Object value)
Determine first location of a value in list. |
Iterator |
iterator()
Returns an iterator traversing list from head to tail. |
int |
lastIndexOf(Object value)
Determine last location of a value in list. |
Object |
remove(int i)
Remove and return value at location i. |
Object |
remove(Object value)
Remove a value from list. |
Object |
removeFirst()
Remove a value from first element of list. |
Object |
removeLast()
Remove last value from list. |
Object |
set(int i,
Object o)
Set value stored at location i to object o, returning old value. |
int |
size()
Determine number of elements in list. |
String |
toString()
Construct a string representing list. |
Methods inherited from class structure.AbstractList |
---|
get, isEmpty, 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 SinglyLinkedList()
Method Detail |
---|
public void add(Object value)
add
in interface List
add
in interface Structure
add
in class AbstractList
value
- The value to be added to tail of list.#addToHead
public void addFirst(Object value)
addFirst
in interface List
addFirst
in class AbstractList
value
- The value to be added to head of list.public Object removeFirst()
removeFirst
in interface List
removeFirst
in class AbstractList
public void addLast(Object value)
addLast
in interface List
addLast
in class AbstractList
value
- The value to be added to tail of list.public Object removeLast()
removeLast
in interface List
removeLast
in class AbstractList
public Object getFirst()
getFirst
in interface List
getFirst
in class AbstractList
public Object getLast()
getLast
in interface List
getLast
in class AbstractList
public boolean contains(Object value)
contains
in interface List
contains
in interface Structure
contains
in class AbstractList
value
- The value sought.
public Object remove(Object value)
value
- The value to be removed.
public int size()
public void clear()
public Object get(int i)
i
- position of value to be retrieved.
public Object set(int i, Object o)
i
- location of entry to be changed.o
- new value
public void add(int i, Object o)
i
- index of this new valueo
- value to be storedpublic Object remove(int i)
i
- position of value to be retrieved.
public int indexOf(Object value)
value
- value sought
public int lastIndexOf(Object value)
value
- value sought.
public Iterator iterator()
AbstractIterator
,
Iterator
,
Enumeration
,
Structure.elements()
public String toString()
toString
in class Object
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |