|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.ws4d.java.structures.DataStructure org.ws4d.java.structures.List org.ws4d.java.structures.LinkedList
public class LinkedList
Implementation of a double linked list. Class is not synchronized.
Constructor Summary | |
---|---|
LinkedList()
Constructor. |
Method Summary | |
---|---|
void |
add(int index,
java.lang.Object obj)
Adds element between the previous and the old element at the specified index position. |
boolean |
add(java.lang.Object obj)
Adds object at the end of the linked list |
boolean |
addAll(DataStructure c)
Add all elements within the data structure at the end of the linked list. |
boolean |
addAll(int index,
DataStructure data)
Add all elements of the given data structure into the list. |
void |
addFirst(java.lang.Object o)
Adds the given element at the beginning of this list. |
void |
clear()
Removes all of the elements from this list. |
java.lang.Object |
get(int index)
|
java.lang.Object |
getFirst()
Returns the first element in this list. |
java.lang.Object |
getLast()
Returns the last element in this list. |
Iterator |
iterator()
Returns an iterator over all items stored within this data structure instance. |
ListIterator |
listIterator(int index)
Returns a list iterator of the list. |
java.lang.Object |
remove(int index)
Removes the element at the specified position in this list. |
java.lang.Object |
removeFirst()
Removes the first element of list and returns it. |
java.lang.Object |
removeLast()
Removes and returns the last element from this list. |
java.lang.Object |
set(int index,
java.lang.Object element)
|
java.lang.Object[] |
toArray()
Returns an array containing all items stored within this data structure. |
java.lang.Object[] |
toArray(java.lang.Object[] array)
Fills array with the elements of this list. |
Methods inherited from class org.ws4d.java.structures.List |
---|
equals, getClassShortName, indexOf, lastIndexOf, listIterator, size, subList |
Methods inherited from class org.ws4d.java.structures.DataStructure |
---|
contains, containsAll, hashCode, isEmpty, remove, toString |
Methods inherited from class java.lang.Object |
---|
getClass, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public LinkedList()
Method Detail |
---|
public void add(int index, java.lang.Object obj) throws java.lang.IndexOutOfBoundsException
add
in class List
index
- position of element to add ( 0==head, size==end of list).obj
- object to add
java.lang.IndexOutOfBoundsException
public boolean add(java.lang.Object obj)
add
in class List
obj
- object to add
true
if the object was actually added,
false
in any other case (e.g. adding an object to a
set which already contains the same object in terms of
java.lang.Object.equals(Object)
)public boolean addAll(DataStructure c)
addAll
in class List
c
- elements to add.
true
if at least one object from data
was actually added, i.e. a modification was made to this
instance, false
in any other case (e.g. adding
objects to a set which already contains them in terms of
java.lang.Object.equals(Object)
)public boolean addAll(int index, DataStructure data) throws java.lang.IndexOutOfBoundsException
addAll
in class List
index
- Index of position to add the new elements at.data
- data structure to add.
true
if this list changed as a result of the call.
java.lang.IndexOutOfBoundsException
- if the specified index is out of rangepublic void addFirst(java.lang.Object o)
o
- element to add.public void clear()
clear
in class DataStructure
public java.lang.Object get(int index) throws java.lang.IndexOutOfBoundsException
get
in class List
java.lang.IndexOutOfBoundsException
public java.lang.Object getFirst()
public java.lang.Object getLast()
public Iterator iterator()
DataStructure
iterator
in class List
public ListIterator listIterator(int index) throws java.lang.IndexOutOfBoundsException
listIterator
in class List
index
- index to start.
java.lang.IndexOutOfBoundsException
- thrown if (index < 0) or (index > size)public java.lang.Object remove(int index) throws java.lang.IndexOutOfBoundsException
remove
in class List
index
- index
java.lang.IndexOutOfBoundsException
- thrown if (index < 0) or (index >=
size)public java.lang.Object removeFirst() throws java.util.NoSuchElementException
java.util.NoSuchElementException
- thrown if no element is in listpublic java.lang.Object removeLast() throws java.util.NoSuchElementException
java.util.NoSuchElementException
public java.lang.Object set(int index, java.lang.Object element) throws java.lang.IndexOutOfBoundsException
set
in class List
java.lang.IndexOutOfBoundsException
public java.lang.Object[] toArray()
DataStructure
DataStructure.size()
, i.e. for an empty data
structure an array of length zero is returned (rather than
null
).
toArray
in class DataStructure
null
public java.lang.Object[] toArray(java.lang.Object[] array)
toArray
in class DataStructure
array
- the array to store this data structure's content to
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |