|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--y.base.YList
YList is an implementation of a doubly linked list.
This implementation provides access to the cells (links) of the list,
which are represented by the class ListCell
. Only objects that are non-null
may be added to this list implementation.
Nested Class Summary | |
class |
YList.ListCursorImpl
Cursor implementation for ylists |
Constructor Summary | |
YList()
Creates an empty doubly linked list. |
|
YList(Collection c)
Creates a list that is initialized with the elements provided by the Collection c . |
|
YList(Iterator it)
Creates a list that is initialized with the elements provided by the Iterator it . |
|
YList(Object[] a)
Creates a list that is initialized with the elements provided by the given array of Objects |
|
YList(YCursor c)
Creates a list that is initialized with the elements provided by the YCursor c . |
|
YList(YCursor c,
DataProvider predicate)
Creates a list containing the objects accessible via the given cursor and for which the given data provider returns true upon
calling its getBool method. |
Method Summary | |
boolean |
add(Object o)
Same as addLast(Object o) . |
boolean |
addAll(Collection collection)
Adds a collection of items to the list. |
void |
addAll(YCursor c)
Appends objects provided by given cursor to this list. |
ListCell |
addFirst(Object o)
Inserts Object o at the head of this list. |
void |
addFirstCell(ListCell cell)
Adds a formerly removed ListCell at the head of this list. |
ListCell |
addLast(Object o)
Inserts Object o at the tail of this list. |
void |
addLastCell(ListCell cell)
Adds a formerly removed ListCell at the tail of this list. |
void |
clear()
Removes all elements from this list. |
boolean |
contains(Object o)
Whether or not this list contains the given element. |
boolean |
containsAll(Collection collection)
Whether or not this list contains the elements given by a collection. |
YCursor |
cursor()
Returns a cursor for this list. |
ListCell |
cyclicPred(ListCell c)
Returns the cyclic predecessor cell of ListCell c . |
ListCell |
cyclicSucc(ListCell c)
Returns the cyclic successor cell of ListCell c . |
Object |
elementAt(int i)
Returns the i-th element in this list. |
ListCell |
findCell(Object o)
Returns the cell where Object o is stored.
|
Object |
first()
Returns the first element in this list. |
ListCell |
firstCell()
Returns the first cell in this list. |
Object |
getInfo(ListCell c)
Returns the element stored in the given ListCell. |
int |
indexOf(Object obj)
Returns the zero-based index of the given element in this list. |
ListCell |
insertAfter(Object o,
ListCell refCell)
Inserts the given object to this list. |
ListCell |
insertBefore(Object o,
ListCell refCell)
Inserts the given object to this list. |
void |
insertCellAfter(ListCell cellToInsert,
ListCell refCell)
Inserts a formerly removed ListCell at the specified position. |
void |
insertCellBefore(ListCell cellToInsert,
ListCell refCell)
Inserts a formerly removed ListCell at the specified position. |
boolean |
isEmpty()
Checks whether this list contains elements |
Iterator |
iterator()
Returns an iterator for that list. |
Object |
last()
Returns the last element in this list. |
ListCell |
lastCell()
Returns the last cell in this list. |
Object |
peek()
Equivalent to first |
Object |
pop()
Removes the first element from this list and returns it. |
Object |
popLast()
Removes the last element from this list and returns it. |
ListCell |
predCell(ListCell c)
Returns the predecessor cell of ListCell c . |
ListCell |
push(Object o)
Equivalent to addFirst |
boolean |
remove(Object o)
Removes Object o from this list. |
boolean |
removeAll(Collection collection)
Removes a collection of objects from the list. |
Object |
removeAt(YCursor c)
Removes the element pointed at by the given YCursor. |
Object |
removeCell(ListCell c)
Removes the ListCell c and the element stored in it from
this list. |
boolean |
retainAll(Collection collection)
Retains only the nodes in the collection which are contained in the specified collection. |
void |
reverse()
Reverses the sequence of elements in this list. |
void |
setInfo(ListCell c,
Object value)
Updates the element residing in the given ListCell. |
int |
size()
Returns the number of elements in this list |
void |
sort()
Sorts the specified array of objects into ascending order, according to the natural ordering of its elements. |
void |
sort(Comparator comp)
Sorts the elements in this list according to the given comparator. |
void |
splice(YList list)
Transfers the contents of the given list to the end of this list. |
ListCell |
succCell(ListCell c)
Returns the successor cell of ListCell c . |
Object[] |
toArray()
Returns an array representation of this List. |
Object[] |
toArray(Object[] a)
Returns an array containing all of the elements in this list in the correct order. |
String |
toString()
Returns a string representation of this List. |
Vector |
toVector()
Returns a vector representation of this List. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Methods inherited from interface java.util.Collection |
equals, hashCode |
Constructor Detail |
public YList()
public YList(Collection c)
c
.
public YList(Iterator it)
it
.
public YList(YCursor c)
c
.
public YList(YCursor c, DataProvider predicate)
true
upon
calling its getBool method.
c
- A cursor providing objects that are initially entered
into this list.predicate
- a dataprovider that acts as a inclusion predicate
for each object accessible from the edge cursorpublic YList(Object[] a)
Method Detail |
public ListCell addFirst(Object o)
o
at the head of this list.
o
is stored.public ListCell addLast(Object o)
o
at the tail of this list.
o
is stored.public void addLastCell(ListCell cell)
cell
- A list cell which is not part of any list.public void addFirstCell(ListCell cell)
cell
- A list cell which is not part of any list.public boolean add(Object o)
addLast(Object o)
.
add
in interface Collection
public boolean addAll(Collection collection)
addAll
in interface Collection
public void addAll(YCursor c)
aList.append(aList.cursor())
will induce
an infinite recursion.
public ListCell insertBefore(Object o, ListCell refCell)
o
- the object to be insertedrefCell
- the cell used to reference the position
o
public void insertCellBefore(ListCell cellToInsert, ListCell refCell)
cellToInsert
- A list cell that is not part of any other list.refCell
- A list cell that is contained in this listpublic void insertCellAfter(ListCell cellToInsert, ListCell refCell)
cellToInsert
- A list cell that is not part of any list.refCell
- A list cell that is contained in this list.public ListCell insertAfter(Object o, ListCell refCell)
o
- the object to be insertedrefCell
- the cell used to reference the position
o
public int size()
size
in interface Collection
public boolean isEmpty()
isEmpty
in interface Collection
public void clear()
clear
in interface Collection
public Object first()
public Object pop()
public ListCell push(Object o)
addFirst
public Object peek()
first
public Object last()
public Object popLast()
public Object elementAt(int i)
public int indexOf(Object obj)
public ListCell firstCell()
public ListCell lastCell()
public ListCell succCell(ListCell c)
c
.
public ListCell predCell(ListCell c)
c
.
public ListCell cyclicSucc(ListCell c)
c
.
public ListCell cyclicPred(ListCell c)
c
.
public Object getInfo(ListCell c)
public void setInfo(ListCell c, Object value)
public boolean remove(Object o)
o
from this list. Only the first element
for which equality to o
holds gets removed.
This operation has time complexity O(size()).
remove
in interface Collection
public boolean removeAll(Collection collection)
removeAll
in interface Collection
public boolean retainAll(Collection collection)
retainAll
in interface Collection
public Object removeCell(ListCell c)
c
and the element stored in it from
this list. This operation has time complexity O(1).
Precondition: c is a cell of this list.
public Object removeAt(YCursor c)
public YCursor cursor()
public Iterator iterator()
iterator
in interface Collection
public boolean contains(Object o)
isEqual
method.
contains
in interface Collection
public boolean containsAll(Collection collection)
isEqual
method.
containsAll
in interface Collection
public ListCell findCell(Object o)
o
is stored.
This operation returns null, if no such cell exists.
public String toString()
toString
in class Object
public Object[] toArray()
toArray
in interface Collection
public Object[] toArray(Object[] a)
If the list fits in the specified array with room to spare (i.e., the array has more elements than the list), the element in the array immediately following the end of the collection is set to null. This is useful in determining the length of the list only if the caller knows that the list does not contain any null elements.
toArray
in interface Collection
ArrayStoreException
- if the runtime type of a is not a
supertype of the runtime type of every element in this list.a
- the array into which the elements of the list are to
be stored, if it is big enough; otherwise, a new array of the
same runtime type is allocated for this purpose.
public Vector toVector()
public void reverse()
public void sort(Comparator comp)
Complexity:: O(size()*log(size()))
public void sort()
Complexity:: O(size()*log(size()))
public void splice(YList list)
Complexity:: O(1)
|
© Copyright 2000-2003, yWorks GmbH. All rights reserved. 2003 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |