|
Search this API | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objecty.base.YList
public class YList
An implementation of a doubly linked list that provides direct access to the
cells that store the elements.
The cells are represented by class ListCell.
firstCell()/lastCell() together with
succCell(ListCell)/predCell(ListCell), respectively) or by
means of a cursor (cursor()).
Furthermore, YList offers its own sort() method.
Note that this class also provides all relevant methods to use the list like
a stack data type.
This implementation permits null as values.
It implements the List interface but does not support the
subList(int, int) method. The implementation of this method will throw an
UnsupportedOperationException if invoked.
The iterator()s returned by instances of this class are fail fast, however
the cursor() implementation is not.
| Nested Class Summary | |
|---|---|
class |
YList.ListCursorImpl
Cursor implementation for class YList. |
| Constructor Summary | |
|---|---|
YList()
Creates an empty doubly linked list. |
|
YList(Collection c)
Creates a list that is initialized with the elements provided by the given Collection object. |
|
YList(Iterator it)
Creates a list that is initialized with the elements provided by the given Iterator object. |
|
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 given YCursor object. |
|
YList(YCursor c,
DataProvider predicate)
Creates a list that is initialized with those elements from the given YCursor object for which the given data provider returns true upon
calling its getBool method. |
|
| Method Summary | |
|---|---|
void |
add(int index,
Object element)
|
boolean |
add(Object o)
Same as addLast(Object). |
boolean |
addAll(Collection collection)
Appends all elements provided by the given collection to this list. |
boolean |
addAll(int index,
Collection c)
|
void |
addAll(YCursor c)
Appends all elements provided by the given cursor to this list. |
ListCell |
addFirst(Object o)
Inserts the given object at the head of this list. |
void |
addFirstCell(ListCell cell)
Adds a formerly removed ListCell object at the head of this list. |
ListCell |
addLast(Object o)
Inserts the given object at the tail of this list. |
void |
addLastCell(ListCell cell)
Adds a formerly removed ListCell object 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 all the elements in the given collection. |
YCursor |
cursor()
Returns a cursor for this list. |
ListCell |
cyclicPred(ListCell c)
Returns the cyclic predecessor cell of the given list cell. |
ListCell |
cyclicSucc(ListCell c)
Returns the cyclic successor cell of the given list cell. |
Object |
elementAt(int i)
Returns the i-th element of this list. |
boolean |
equals(Object other)
|
ListCell |
findCell(Object o)
Returns the ListCell where object o is stored. |
Object |
first()
Returns the first element of this list. |
ListCell |
firstCell()
Returns the first cell of this list. |
Object |
get(int index)
|
ListCell |
getCell(int index)
Gets the cell at the given index. |
Object |
getInfo(ListCell c)
Returns the element stored in the given list cell. |
int |
hashCode()
|
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 into this list with respect to a given reference list cell. |
ListCell |
insertBefore(Object o,
ListCell refCell)
Inserts the given object into this list with respect to a given reference list cell. |
void |
insertCellAfter(ListCell cellToInsert,
ListCell refCell)
Inserts a formerly removed ListCell object into this list with respect to a given reference list cell. |
void |
insertCellBefore(ListCell cellToInsert,
ListCell refCell)
Inserts a formerly removed ListCell object into this list with respect to a given reference list cell. |
boolean |
isEmpty()
Checks whether this list contains elements. |
Iterator |
iterator()
Returns an iterator for that list. |
Object |
last()
Returns the last element of this list. |
ListCell |
lastCell()
Returns the last cell of this list. |
int |
lastIndexOf(Object o)
|
ListIterator |
listIterator()
|
ListIterator |
listIterator(int index)
|
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 the given list cell. |
ListCell |
push(Object o)
Equivalent to addFirst(Object). |
Object |
remove(int index)
|
boolean |
remove(Object o)
Removes the given object from this list. |
boolean |
removeAll(Collection collection)
Removes the given collection of objects from this list. |
Object |
removeAt(YCursor c)
Removes the element pointed to by the given YCursor object. |
Object |
removeCell(ListCell c)
Removes the given list cell, and hence the element stored in it, from this list. |
boolean |
retainAll(Collection collection)
Retains only those elements in this list which are contained in the given collection. |
void |
reverse()
Reverses the sequence of elements in this list. |
Object |
set(int index,
Object element)
|
void |
setInfo(ListCell c,
Object value)
Updates the element stored in the given list cell with the given object. |
int |
size()
Returns the number of elements in this list. |
void |
sort()
Sorts the elements in this list into ascending order, according to their natural ordering. |
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. |
List |
subList(int fromIndex,
int toIndex)
|
ListCell |
succCell(ListCell c)
Returns the successor cell of the given list cell. |
Object[] |
toArray()
Returns an array representation of this list. |
Object[] |
toArray(Object[] a)
Returns an array containing all list elements 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, finalize, getClass, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public YList()
public YList(Collection c)
public YList(Iterator it)
public YList(YCursor c)
public YList(YCursor c,
DataProvider predicate)
true upon
calling its getBool method.
c - A cursor providing objects that should be added to this list.predicate - A data provider that acts as a inclusion predicate for each object accessible
by the given cursor.public YList(Object[] a)
| Method Detail |
|---|
public ListCell addFirst(Object o)
public ListCell addLast(Object o)
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).
add in interface Collectionadd in interface Listtruepublic boolean addAll(Collection collection)
addAll in interface CollectionaddAll in interface Listpublic void addAll(YCursor c)
aList.append(aList.cursor()) results
in an infinite recursion.
public ListCell insertBefore(Object o,
ListCell refCell)
refCell.
If refCell == null, the given object is appended to the list.
o - The object to be inserted.refCell - The list cell used to reference the position.
o.refCell must be part of this list.
public void insertCellBefore(ListCell cellToInsert,
ListCell refCell)
refCell.
Attention: If the ListCell object is still part of any list, then that
list will be corrupted afterwards.
cellToInsert - A list cell which is not part of any list.refCell - The list cell used to reference the position.refCell must be part of this list.
public void insertCellAfter(ListCell cellToInsert,
ListCell refCell)
refCell.
Attention: If the ListCell object is still part of any list, then that
list will be corrupted afterwards.
cellToInsert - A list cell which is not part of any list.refCell - The list cell used to reference the position.refCell must be part of this list.
public ListCell insertAfter(Object o,
ListCell refCell)
refCell.
If refCell == null, the given object is inserted at the head of
the list.
o - The object to be inserted.refCell - The list cell used to reference the position.
o.refCell must be part of this list.public int size()
size in interface Collectionsize in interface Listpublic boolean isEmpty()
isEmpty in interface CollectionisEmpty in interface Listpublic void clear()
clear in interface Collectionclear in interface Listpublic Object first()
!isEmpty().public Object pop()
public ListCell push(Object o)
addFirst(Object).
public Object peek()
first().
public Object last()
!isEmpty().public Object popLast()
public Object elementAt(int i)
i is a valid index, i.e., i >= 0 && i < size().public int indexOf(Object obj)
indexOf in interface Listpublic ListCell firstCell()
!isEmpty().public ListCell lastCell()
!isEmpty().public ListCell succCell(ListCell c)
public ListCell predCell(ListCell c)
public ListCell cyclicSucc(ListCell c)
public ListCell cyclicPred(ListCell c)
public Object getInfo(ListCell c)
public void setInfo(ListCell c,
Object value)
public boolean remove(Object o)
o holds gets removed.
remove in interface Collectionremove in interface Listpublic boolean removeAll(Collection collection)
removeAll in interface CollectionremoveAll in interface Listpublic boolean retainAll(Collection collection)
retainAll in interface CollectionretainAll in interface Listpublic Object removeCell(ListCell c)
public Object removeAt(YCursor c)
cursor()
method and the element pointed to by it is contained in this list.public YCursor cursor()
public Iterator iterator()
iterator in interface Iterableiterator in interface Collectioniterator in interface Listpublic ListIterator listIterator()
listIterator in interface Listpublic boolean contains(Object o)
Object.equals(Object) method.
contains in interface Collectioncontains in interface Listpublic boolean containsAll(Collection collection)
Object.equals(Object) method.
containsAll in interface CollectioncontainsAll in interface Listpublic ListCell findCell(Object o)
ListCell where object o is stored.
This operation returns null, if no such cell exists.
Equality of elements is defined by the Object.equals(Object) method.
The first element in the list that matches that criteria is returned.
null if no
such ListCell was foundpublic String toString()
toString in class Objectpublic Object[] toArray()
toArray in interface CollectiontoArray in interface Listpublic Object[] toArray(Object[] a)
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 CollectiontoArray in interface ListArrayStoreException - if the runtime type of the specified array 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)
public void sort()
Comparable interface.
Furthermore, all elements in this list must be mutually comparable (that is,
e1.compareTo(e2) must not throw a ClassCastException for any elements
e1 and e2 in this list).
NOTE: The elements will be assigned to different list cells by this method.
public void splice(YList list)
public boolean addAll(int index,
Collection c)
addAll in interface Listpublic final ListCell getCell(int index)
IndexOutOfBoundsException - if the index is negative or greater or equal than the size()index - the zero-based index of the cell in this list.
public int lastIndexOf(Object o)
lastIndexOf in interface List
public Object set(int index,
Object element)
set in interface Listpublic Object remove(int index)
remove in interface Listpublic ListIterator listIterator(int index)
listIterator in interface Listpublic Object get(int index)
get in interface List
public void add(int index,
Object element)
add in interface List
public List subList(int fromIndex,
int toIndex)
subList in interface Listpublic boolean equals(Object other)
equals in interface Collectionequals in interface Listequals in class Objectpublic int hashCode()
hashCode in interface CollectionhashCode in interface ListhashCode in class Object
|
© Copyright 2000-2013, yWorks GmbH. All rights reserved. |
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||