soot.util
Class HashChain

java.lang.Object
  |
  +--java.util.AbstractCollection
        |
        +--soot.util.HashChain
All Implemented Interfaces:
Chain, java.util.Collection

public class HashChain
extends java.util.AbstractCollection
implements Chain

Reference implementation of the Chain interface, using a HashMap as the underlying structure.


Constructor Summary
HashChain()
          Constructs an empty HashChain.
 
Method Summary
 boolean add(java.lang.Object item)
          Adds the given object to this HashChain.
 void addFirst(java.lang.Object item)
          Adds the given object at the beginning of the Chain.
 void addLast(java.lang.Object 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(java.lang.Object someObject, java.lang.Object someReferenceObject)
          Returns true if object someObject follows object someReferenceObject in the Chain.
 java.lang.Object getFirst()
          Returns the first object in this Chain.
 java.lang.Object getLast()
          Returns the last object in this Chain.
 java.lang.Object getPredOf(java.lang.Object point)
          Returns the object immediately preceding point.
 java.lang.Object getSuccOf(java.lang.Object point)
          Returns the object immediately following point.
 void insertAfter(java.util.List toInsert, java.lang.Object point)
          Inserts toInsert in the Chain after point.
 void insertAfter(java.lang.Object toInsert, java.lang.Object point)
          Inserts toInsert in the Chain after point.
 void insertBefore(java.util.List toInsert, java.lang.Object point)
          Inserts toInsert in the Chain before point.
 void insertBefore(java.lang.Object toInsert, java.lang.Object point)
          Inserts toInsert in the Chain before point.
 java.util.Iterator iterator()
          Returns an iterator over this Chain.
 java.util.Iterator iterator(java.lang.Object item)
          Returns an iterator over this Chain, starting at the given object.
 java.util.Iterator iterator(java.lang.Object head, java.lang.Object tail)
          Returns an iterator ranging from head to tail, inclusive.
static HashChain listToHashChain(java.util.List 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 snapshotIterator()
          Returns an iterator over a copy of this chain.
 void swapWith(java.lang.Object out, java.lang.Object in)
          Replaces out in the Chain by in.
static java.util.List toList(Chain c)
          Returns an unbacked list containing the contents of the given Chain.
 java.lang.String toString()
          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, removeAll, retainAll, toArray, toArray
 

Constructor Detail

HashChain

public HashChain()
Constructs an empty HashChain.
Method Detail

clear

public void clear()
Erases the contents of the current HashChain.
Specified by:
clear in interface java.util.Collection
Overrides:
clear in class java.util.AbstractCollection

swapWith

public void swapWith(java.lang.Object out,
                     java.lang.Object in)
Description copied from interface: Chain
Replaces out in the Chain by in.
Specified by:
swapWith in interface Chain

add

public boolean add(java.lang.Object item)
Adds the given object to this HashChain.
Specified by:
add in interface java.util.Collection
Overrides:
add in class java.util.AbstractCollection

toList

public static java.util.List toList(Chain c)
Returns an unbacked list containing the contents of the given Chain.

follows

public boolean follows(java.lang.Object someObject,
                       java.lang.Object someReferenceObject)
Description copied from interface: Chain
Returns true if object someObject follows object someReferenceObject in the Chain.
Specified by:
follows in interface Chain

contains

public boolean contains(java.lang.Object o)
Specified by:
contains in interface java.util.Collection
Overrides:
contains in class java.util.AbstractCollection

containsAll

public boolean containsAll(java.util.Collection c)
Specified by:
containsAll in interface java.util.Collection
Overrides:
containsAll in class java.util.AbstractCollection

insertAfter

public void insertAfter(java.lang.Object toInsert,
                        java.lang.Object point)
Description copied from interface: Chain
Inserts toInsert in the Chain after point.
Specified by:
insertAfter in interface Chain

insertAfter

public void insertAfter(java.util.List toInsert,
                        java.lang.Object point)
Description copied from interface: Chain
Inserts toInsert in the Chain after point.
Specified by:
insertAfter in interface Chain

insertBefore

public void insertBefore(java.util.List toInsert,
                         java.lang.Object point)
Description copied from interface: Chain
Inserts toInsert in the Chain before point.
Specified by:
insertBefore in interface Chain

listToHashChain

public static HashChain listToHashChain(java.util.List list)

insertBefore

public void insertBefore(java.lang.Object toInsert,
                         java.lang.Object point)
Description copied from interface: Chain
Inserts toInsert in the Chain before point.
Specified by:
insertBefore in interface Chain

remove

public boolean remove(java.lang.Object item)
Description copied from interface: Chain
Removes the given object from this Chain.
Specified by:
remove in interface Chain
Overrides:
remove in class java.util.AbstractCollection

addFirst

public void addFirst(java.lang.Object item)
Description copied from interface: Chain
Adds the given object at the beginning of the Chain.
Specified by:
addFirst in interface Chain

addLast

public void addLast(java.lang.Object item)
Description copied from interface: Chain
Adds the given object at the end of the Chain.
Specified by:
addLast in interface Chain

removeFirst

public void removeFirst()
Description copied from interface: Chain
Removes the first object contained in this Chain.
Specified by:
removeFirst in interface Chain

removeLast

public void removeLast()
Description copied from interface: Chain
Removes the last object contained in this Chain.
Specified by:
removeLast in interface Chain

getFirst

public java.lang.Object getFirst()
Description copied from interface: Chain
Returns the first object in this Chain.
Specified by:
getFirst in interface Chain

getLast

public java.lang.Object getLast()
Description copied from interface: Chain
Returns the last object in this Chain.
Specified by:
getLast in interface Chain

getSuccOf

public java.lang.Object getSuccOf(java.lang.Object point)
                           throws java.util.NoSuchElementException
Description copied from interface: Chain
Returns the object immediately following point.
Specified by:
getSuccOf in interface Chain

getPredOf

public java.lang.Object getPredOf(java.lang.Object point)
                           throws java.util.NoSuchElementException
Description copied from interface: Chain
Returns the object immediately preceding point.
Specified by:
getPredOf in interface Chain

snapshotIterator

public java.util.Iterator snapshotIterator()
Description copied from interface: Chain
Returns 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:
snapshotIterator in interface Chain

iterator

public java.util.Iterator iterator()
Description copied from interface: Chain
Returns an iterator over this Chain.
Specified by:
iterator in interface Chain
Overrides:
iterator in class java.util.AbstractCollection

iterator

public java.util.Iterator iterator(java.lang.Object item)
Description copied from interface: Chain
Returns an iterator over this Chain, starting at the given object.
Specified by:
iterator in interface Chain

iterator

public java.util.Iterator iterator(java.lang.Object head,
                                   java.lang.Object tail)
Returns an iterator ranging from head to tail, inclusive.
Specified by:
iterator in interface Chain

size

public int size()
Description copied from interface: Chain
Returns the size of this Chain.
Specified by:
size in interface Chain
Overrides:
size in class java.util.AbstractCollection

toString

public java.lang.String toString()
Returns a textual representation of the contents of this Chain.
Overrides:
toString in class java.util.AbstractCollection