soot.util
Interface Chain<E>

Type Parameters:
E - element type
All Superinterfaces:
Collection<E>, Iterable<E>, Serializable
All Known Implementing Classes:
HashChain, IterableSet, PatchingChain, PegChain, SPatchingChain

public interface Chain<E>
extends Collection<E>, Serializable

Augmented data type guaranteeing O(1) insertion and removal from a set of ordered, unique elements.


Method Summary
 void addFirst(E u)
          Adds the given object at the beginning of the Chain.
 void addLast(E u)
          Adds the given object at the end of the Chain.
 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.
 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(E toInsert, E point)
          Inserts toInsert in the Chain after point.
 void insertAfter(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(E toInsert, E point)
          Inserts toInsert in the Chain before point.
 void insertBefore(List<E> toInsert, E point)
          Inserts toInsert in the Chain before point.
 Iterator<E> iterator()
          Returns an iterator over this Chain.
 Iterator<E> iterator(E u)
          Returns an iterator over this Chain, starting at the given object.
 Iterator<E> iterator(E head, E tail)
          Returns an iterator over this Chain, starting at head and reaching tail (inclusive).
 boolean remove(Object u)
          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.
 Iterator<E> snapshotIterator()
          Returns an iterator over a copy of this chain.
 void swapWith(E out, E in)
          Replaces out in the Chain by in.
 
Methods inherited from interface java.util.Collection
add, addAll, clear, contains, containsAll, equals, hashCode, isEmpty, removeAll, retainAll, toArray, toArray
 

Method Detail

insertBefore

void insertBefore(List<E> toInsert,
                  E point)
Inserts toInsert in the Chain before point.


insertAfter

void insertAfter(List<E> toInsert,
                 E point)
Inserts toInsert in the Chain after point.


insertAfter

void insertAfter(E toInsert,
                 E point)
Inserts toInsert in the Chain after point.


insertBefore

void insertBefore(E toInsert,
                  E point)
Inserts toInsert in the Chain before point.


insertBefore

void insertBefore(Chain<E> toInsert,
                  E point)
Inserts toInsert in the Chain before point. (It would probably be better to make Chain implement List)


insertAfter

void insertAfter(Chain<E> toInsert,
                 E point)
Inserts toInsert in the Chain after point. (It would probably be better to make Chain implement List)


swapWith

void swapWith(E out,
              E in)
Replaces out in the Chain by in.


remove

boolean remove(Object u)
Removes the given object from this Chain. Parameter has to be of type Object to be compatible with the Collection interface.

Specified by:
remove in interface Collection<E>

addFirst

void addFirst(E u)
Adds the given object at the beginning of the Chain.


addLast

void addLast(E u)
Adds the given object at the end of the Chain.


removeFirst

void removeFirst()
Removes the first object contained in this Chain.


removeLast

void removeLast()
Removes the last object contained in this Chain.


follows

boolean follows(E someObject,
                E someReferenceObject)
Returns true if object someObject follows object someReferenceObject in the Chain.


getFirst

E getFirst()
Returns the first object in this Chain.


getLast

E getLast()
Returns the last object in this Chain.


getSuccOf

E getSuccOf(E point)
Returns the object immediately following point.


getPredOf

E getPredOf(E point)
Returns the object immediately preceding point.


snapshotIterator

Iterator<E> snapshotIterator()
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!


iterator

Iterator<E> iterator()
Returns an iterator over this Chain.

Specified by:
iterator in interface Collection<E>
Specified by:
iterator in interface Iterable<E>

iterator

Iterator<E> iterator(E u)
Returns an iterator over this Chain, starting at the given object.


iterator

Iterator<E> iterator(E head,
                     E tail)
Returns an iterator over this Chain, starting at head and reaching tail (inclusive).


size

int size()
Returns the size of this Chain.

Specified by:
size in interface Collection<E>