Package soot.util
Class HashChain<E>
- java.lang.Object
-
- java.util.AbstractCollection<E>
-
- soot.util.HashChain<E>
-
- All Implemented Interfaces:
Serializable,Iterable<E>,Collection<E>,Chain<E>
- Direct Known Subclasses:
IterableSet,PegChain
public class HashChain<E> extends AbstractCollection<E> implements Chain<E>
Reference implementation of the Chain interface, using a HashMap as the underlying structure.- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected classHashChain.Link<X extends E>protected classHashChain.LinkIterator<X extends E>
-
Field Summary
Fields Modifier and Type Field Description protected EfirstItemprotected ElastItemprotected Map<E,HashChain.Link<E>>mapprotected intstateCount
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description booleanadd(E item)Adds the given object to this HashChain.voidaddFirst(E item)Adds the given object at the beginning of the Chain.voidaddLast(E item)Adds the given object at the end of the Chain.voidclear()Erases the contents of the current HashChain.booleancontains(Object o)booleancontainsAll(Collection<?> c)protected static <X> Iterator<X>emptyIterator()booleanfollows(E someObject, E someReferenceObject)Returns true if objectsomeObjectfollows objectsomeReferenceObjectin the Chain, i.e.Collection<E>getElementsUnsorted()Gets all elements in the chain.EgetFirst()Returns the first object in this Chain.EgetLast()Returns the last object in this Chain.longgetModificationCount()Returns the number of times this chain has been modified.EgetPredOf(E point)Returns the object immediately precedingpoint.EgetSuccOf(E point)Returns the object immediately followingpoint.voidinsertAfter(E toInsert, E point)InsertstoInsertin the Chain afterpoint.voidinsertAfter(Collection<? extends E> toInsert, E point)InsertstoInsertin the Chain afterpoint.voidinsertAfter(List<E> toInsert, E point)InsertstoInsertin the Chain afterpoint.voidinsertAfter(Chain<E> toInsert, E point)InsertstoInsertin the Chain afterpoint.voidinsertBefore(E toInsert, E point)InsertstoInsertin the Chain beforepoint.voidinsertBefore(Collection<? extends E> toInsert, E point)InsertstoInsertin the Chain beforepoint.voidinsertBefore(List<E> toInsert, E point)InsertstoInsertin the Chain beforepoint.voidinsertBefore(Chain<E> toInsert, E point)InsertstoInsertin the Chain beforepoint.Iterator<E>iterator()Returns an iterator over this Chain.Iterator<E>iterator(E from)Returns an iterator over this Chain, starting at the given object.Iterator<E>iterator(E head, E tail)Returns an iterator ranging fromheadtotail, inclusive.static <T> HashChain<T>listToHashChain(List<T> list)booleanremove(Object item)Removes the given object from this Chain.voidremoveFirst()Removes the first object contained in this Chain.voidremoveLast()Removes the last object contained in this Chain.intsize()Returns the size of this Chain.Iterator<E>snapshotIterator()Returns an iterator over a copy of this chain.Iterator<E>snapshotIterator(E from)voidswapWith(E out, E in)Replacesoutin the Chain byin.static <E> List<E>toList(Chain<E> c)Deprecated.you can usenew ArrayListinstead(c) StringtoString()Returns a textual representation of the contents of this Chain.-
Methods inherited from class java.util.AbstractCollection
addAll, isEmpty, removeAll, retainAll, toArray, toArray
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface java.util.Collection
addAll, equals, hashCode, isEmpty, parallelStream, removeAll, removeIf, retainAll, spliterator, stream, toArray, toArray, toArray
-
-
-
-
Method Detail
-
emptyIterator
protected static <X> Iterator<X> emptyIterator()
-
clear
public void clear()
Erases the contents of the current HashChain.- Specified by:
clearin interfaceCollection<E>- Overrides:
clearin classAbstractCollection<E>
-
swapWith
public void swapWith(E out, E in)
Description copied from interface:ChainReplacesoutin the Chain byin.
-
add
public boolean add(E item)
Adds the given object to this HashChain.- Specified by:
addin interfaceCollection<E>- Overrides:
addin classAbstractCollection<E>
-
getElementsUnsorted
public Collection<E> getElementsUnsorted()
Gets all elements in the chain. There is no guarantee on sorting.- Specified by:
getElementsUnsortedin interfaceChain<E>- Returns:
- All elements in the chain in an unsorted collection
-
toList
@Deprecated public static <E> List<E> toList(Chain<E> c)
Deprecated.you can usenew ArrayListinstead(c) Returns an unbacked list containing the contents of the given Chain.
-
follows
public boolean follows(E someObject, E someReferenceObject)
Description copied from interface:ChainReturns true if objectsomeObjectfollows objectsomeReferenceObjectin the Chain, i.e. someReferenceObject comes first and then someObject.
-
contains
public boolean contains(Object o)
- Specified by:
containsin interfaceCollection<E>- Overrides:
containsin classAbstractCollection<E>
-
containsAll
public boolean containsAll(Collection<?> c)
- Specified by:
containsAllin interfaceCollection<E>- Overrides:
containsAllin classAbstractCollection<E>
-
insertAfter
public void insertAfter(E toInsert, E point)
Description copied from interface:ChainInsertstoInsertin the Chain afterpoint.- Specified by:
insertAfterin interfaceChain<E>
-
insertAfter
public void insertAfter(Collection<? extends E> toInsert, E point)
Description copied from interface:ChainInsertstoInsertin the Chain afterpoint.- Specified by:
insertAfterin interfaceChain<E>
-
insertAfter
public void insertAfter(List<E> toInsert, E point)
Description copied from interface:ChainInsertstoInsertin the Chain afterpoint.- Specified by:
insertAfterin interfaceChain<E>
-
insertAfter
public void insertAfter(Chain<E> toInsert, E point)
Description copied from interface:ChainInsertstoInsertin the Chain afterpoint.- Specified by:
insertAfterin interfaceChain<E>
-
insertBefore
public void insertBefore(E toInsert, E point)
Description copied from interface:ChainInsertstoInsertin the Chain beforepoint.- Specified by:
insertBeforein interfaceChain<E>
-
insertBefore
public void insertBefore(Collection<? extends E> toInsert, E point)
Description copied from interface:ChainInsertstoInsertin the Chain beforepoint.- Specified by:
insertBeforein interfaceChain<E>
-
insertBefore
public void insertBefore(List<E> toInsert, E point)
Description copied from interface:ChainInsertstoInsertin the Chain beforepoint.- Specified by:
insertBeforein interfaceChain<E>
-
insertBefore
public void insertBefore(Chain<E> toInsert, E point)
Description copied from interface:ChainInsertstoInsertin the Chain beforepoint.- Specified by:
insertBeforein interfaceChain<E>
-
remove
public boolean remove(Object item)
Description copied from interface:ChainRemoves the given object from this Chain. Parameter has to be of typeObjectto be compatible with theCollectioninterface.- Specified by:
removein interfaceChain<E>- Specified by:
removein interfaceCollection<E>- Overrides:
removein classAbstractCollection<E>
-
addFirst
public void addFirst(E item)
Description copied from interface:ChainAdds the given object at the beginning of the Chain.
-
addLast
public void addLast(E item)
Description copied from interface:ChainAdds the given object at the end of the Chain.
-
removeFirst
public void removeFirst()
Description copied from interface:ChainRemoves the first object contained in this Chain.- Specified by:
removeFirstin interfaceChain<E>
-
removeLast
public void removeLast()
Description copied from interface:ChainRemoves the last object contained in this Chain.- Specified by:
removeLastin interfaceChain<E>
-
getFirst
public E getFirst()
Description copied from interface:ChainReturns the first object in this Chain.
-
getLast
public E getLast()
Description copied from interface:ChainReturns the last object in this Chain.
-
getSuccOf
public E getSuccOf(E point) throws NoSuchElementException
Description copied from interface:ChainReturns the object immediately followingpoint.- Specified by:
getSuccOfin interfaceChain<E>- Throws:
NoSuchElementException
-
getPredOf
public E getPredOf(E point) throws NoSuchElementException
Description copied from interface:ChainReturns the object immediately precedingpoint.- Specified by:
getPredOfin interfaceChain<E>- Throws:
NoSuchElementException
-
snapshotIterator
public Iterator<E> snapshotIterator()
Description copied from interface:ChainReturns an iterator over a copy of this chain. This avoids ConcurrentModificationExceptions from being thrown if the underlying Chain is modified during iteration. Do not use this to remove elements which have not yet been iterated over!- Specified by:
snapshotIteratorin interfaceChain<E>
-
iterator
public Iterator<E> iterator()
Description copied from interface:ChainReturns an iterator over this Chain.
-
iterator
public Iterator<E> iterator(E from)
Description copied from interface:ChainReturns an iterator over this Chain, starting at the given object.
-
iterator
public Iterator<E> iterator(E head, E tail)
Returns an iterator ranging from
headtotail, inclusive.If
tailis the element immediately precedingheadin thisHashChain, the returned iterator will iterate 0 times (a special case to allow the specification of an empty range of elements). Otherwise iftailis not one of the elements followinghead, the returned iterator will iterate past the end of theHashChain, provoking aNoSuchElementException.- Specified by:
iteratorin interfaceChain<E>- Throws:
NoSuchElementException- ifheadis not an element of the chain.
-
size
public int size()
Description copied from interface:ChainReturns the size of this Chain.- Specified by:
sizein interfaceChain<E>- Specified by:
sizein interfaceCollection<E>- Specified by:
sizein classAbstractCollection<E>
-
toString
public String toString()
Returns a textual representation of the contents of this Chain.- Overrides:
toStringin classAbstractCollection<E>
-
getModificationCount
public long getModificationCount()
Returns the number of times this chain has been modified.- Specified by:
getModificationCountin interfaceChain<E>
-
-