public class HashChain<E> extends java.util.AbstractCollection<E> implements Chain<E>
| Constructor and Description |
|---|
HashChain()
Constructs an empty HashChain.
|
HashChain(Chain<E> src)
Constructs a HashChain filled with the contents of the src Chain.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
add(E item)
Adds the given object to this HashChain.
|
void |
addFirst(E item)
Adds the given object at the beginning of the Chain.
|
void |
addLast(E item)
Adds the given object at the end of the Chain.
|
void |
clear()
Erases the contents of the current HashChain.
|
boolean |
contains(java.lang.Object o) |
boolean |
containsAll(java.util.Collection<?> c) |
boolean |
follows(E someObject,
E someReferenceObject)
Returns true if object
someObject follows object someReferenceObject in the Chain. |
E |
getFirst()
Returns the first object in this Chain.
|
E |
getLast()
Returns the last object in this Chain.
|
long |
getModificationCount()
Returns the number of times this chain has been modified.
|
E |
getPredOf(E point)
Returns the object immediately preceding
point. |
E |
getSuccOf(E point)
Returns the object immediately following
point. |
void |
insertAfter(Chain<E> toInsert,
E point)
Inserts
toInsert in the Chain after point. |
void |
insertAfter(java.util.Collection<? extends E> toInsert,
E point) |
void |
insertAfter(E toInsert,
E point)
Inserts
toInsert in the Chain after point. |
void |
insertAfter(java.util.List<E> toInsert,
E point)
Inserts
toInsert in the Chain after point. |
void |
insertBefore(Chain<E> toInsert,
E point)
Inserts
toInsert in the Chain before point. |
void |
insertBefore(java.util.Collection<? extends E> toInsert,
E point) |
void |
insertBefore(E toInsert,
E point)
Inserts
toInsert in the Chain before point. |
void |
insertBefore(java.util.List<E> toInsert,
E point)
Inserts
toInsert in the Chain before point. |
java.util.Iterator<E> |
iterator()
Returns an iterator over this Chain.
|
java.util.Iterator<E> |
iterator(E item)
Returns an iterator over this Chain, starting at the given object.
|
java.util.Iterator<E> |
iterator(E head,
E tail)
Returns an iterator ranging from
head to tail,
inclusive. |
static <T> HashChain<T> |
listToHashChain(java.util.List<T> list) |
boolean |
remove(java.lang.Object item)
Removes the given object from this Chain.
|
void |
removeFirst()
Removes the first object contained in this Chain.
|
void |
removeLast()
Removes the last object contained in this Chain.
|
int |
size()
Returns the size of this Chain.
|
java.util.Iterator<E> |
snapshotIterator()
Returns an iterator over a copy of this chain.
|
java.util.Iterator<E> |
snapshotIterator(E item) |
void |
swapWith(E out,
E in)
Replaces
out in the Chain by in. |
static <E> java.util.List<E> |
toList(Chain<E> c)
Deprecated.
you can use
new ArrayList instead |
java.lang.String |
toString()
Returns a textual representation of the contents of this Chain.
|
addAll, isEmpty, removeAll, retainAll, toArray, toArraypublic void clear()
public void swapWith(E out, E in)
Chainout in the Chain by in.public boolean add(E item)
@Deprecated public static <E> java.util.List<E> toList(Chain<E> c)
new ArrayList(c) insteadpublic boolean follows(E someObject, E someReferenceObject)
ChainsomeObject follows object someReferenceObject in the Chain.public boolean contains(java.lang.Object o)
public boolean containsAll(java.util.Collection<?> c)
public void insertAfter(E toInsert, E point)
ChaintoInsert in the Chain after point.insertAfter in interface Chain<E>public void insertAfter(java.util.List<E> toInsert, E point)
ChaintoInsert in the Chain after point.insertAfter in interface Chain<E>public void insertAfter(Chain<E> toInsert, E point)
ChaintoInsert in the Chain after point.
(It would probably be better to make Chain implement List)insertAfter in interface Chain<E>public void insertBefore(E toInsert, E point)
ChaintoInsert in the Chain before point.insertBefore in interface Chain<E>public void insertBefore(java.util.List<E> toInsert, E point)
ChaintoInsert in the Chain before point.insertBefore in interface Chain<E>public void insertBefore(Chain<E> toInsert, E point)
ChaintoInsert in the Chain before point.
(It would probably be better to make Chain implement List)insertBefore in interface Chain<E>public static <T> HashChain<T> listToHashChain(java.util.List<T> list)
public boolean remove(java.lang.Object item)
ChainObject to be compatible
with the Collection interface.public void addFirst(E item)
Chainpublic void addLast(E item)
Chainpublic void removeFirst()
ChainremoveFirst in interface Chain<E>public void removeLast()
ChainremoveLast in interface Chain<E>public E getFirst()
Chainpublic E getLast()
Chainpublic E getSuccOf(E point) throws java.util.NoSuchElementException
Chainpoint.public E getPredOf(E point) throws java.util.NoSuchElementException
Chainpoint.public java.util.Iterator<E> snapshotIterator()
ChainsnapshotIterator in interface Chain<E>public java.util.Iterator<E> iterator()
Chainpublic java.util.Iterator<E> iterator(E item)
Chainpublic java.util.Iterator<E> iterator(E head, E tail)
Returns an iterator ranging from head to tail,
inclusive.
If tail is the element immediately preceding
head in this HashChain, the returned iterator
will iterate 0 times (a special case to allow the specification of an
empty range of elements). Otherwise if tail is not one of
the elements following head, the returned iterator will
iterate past the end of the HashChain, provoking a
NoSuchElementException.
public int size()
Chainpublic java.lang.String toString()
toString in class java.util.AbstractCollection<E>public long getModificationCount()
getModificationCount in interface Chain<E>