- java.lang.Object
-
- java.util.AbstractCollection<E>
-
- soot.PatchingChain<E>
-
- All Implemented Interfaces:
Serializable,Iterable<E>,Collection<E>,Chain<E>
- Direct Known Subclasses:
UnitPatchingChain
public class PatchingChain<E extends Unit> extends AbstractCollection<E> implements Chain<E>
An implementation of a Chain which can contain only Units, and handles patching to deal with element insertions and removals. This is done by calling Unit.redirectJumpsToThisTo at strategic times.- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected classPatchingChain.PatchingIterator
-
Field Summary
Fields Modifier and Type Field Description protected Chain<E>innerChain
-
Constructor Summary
Constructors Constructor Description PatchingChain(Chain<E> aChain)Constructs a PatchingChain from the given Chain.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanadd(E o)Adds the given object to this Chain.voidaddFirst(E u)Adds the given object at the beginning of the Chain.voidaddLast(E u)Adds the given object at the end of the Chain.booleancontains(Object u)Returns true if this patching chain contains the specified element.booleanfollows(E a, E b)Returns true if objectafollows objectbin the Chain.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.Chain<E>getNonPatchingChain()Returns the inner chain used by the PatchingChain.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.voidinsertBeforeNoRedirect(E toInsert, E point)InsertstoInsertin the Chain beforepointWITHOUT redirecting jumps.voidinsertBeforeNoRedirect(List<E> toInsert, E point)InsertstoInsertin the Chain beforepointWITHOUT redirecting jumps.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).protected static <E extends Unit>
voidpatchBeforeRemoval(Chain<E> chain, E removing)booleanremove(Object obj)Removes the given object from this Chain.voidremoveFirst()Removes the first object from this Chain.voidremoveLast()Removes the last object from this Chain.intsize()Returns the size of this Chain.Iterator<E>snapshotIterator()Returns an iterator over a copy of this chain.voidswapWith(E out, E in)Replacesoutin the Chain byin.-
Methods inherited from class java.util.AbstractCollection
addAll, clear, containsAll, isEmpty, removeAll, retainAll, toArray, toArray, toString
-
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, clear, containsAll, equals, hashCode, isEmpty, parallelStream, removeAll, removeIf, retainAll, spliterator, stream, toArray, toArray, toArray
-
-
-
-
Method Detail
-
getNonPatchingChain
public Chain<E> getNonPatchingChain()
Returns the inner chain used by the PatchingChain. In general, this should not be used. However, direct access to the inner chain may be necessary if you wish to perform certain operations (such as control-flow manipulations) without interference from the patching algorithms.
-
add
public boolean add(E o)
Adds the given object to this Chain.- Specified by:
addin interfaceCollection<E extends Unit>- Overrides:
addin classAbstractCollection<E extends Unit>
-
insertAfter
public void insertAfter(E toInsert, E point)
InsertstoInsertin the Chain afterpoint.- Specified by:
insertAfterin interfaceChain<E extends Unit>
-
insertAfter
public void insertAfter(List<E> toInsert, E point)
InsertstoInsertin the Chain afterpoint.- Specified by:
insertAfterin interfaceChain<E extends Unit>
-
insertAfter
public void insertAfter(Chain<E> toInsert, E point)
Description copied from interface:ChainInsertstoInsertin the Chain afterpoint.- Specified by:
insertAfterin interfaceChain<E extends Unit>
-
insertAfter
public void insertAfter(Collection<? extends E> toInsert, E point)
Description copied from interface:ChainInsertstoInsertin the Chain afterpoint.- Specified by:
insertAfterin interfaceChain<E extends Unit>
-
insertBefore
public void insertBefore(List<E> toInsert, E point)
InsertstoInsertin the Chain beforepoint.- Specified by:
insertBeforein interfaceChain<E extends Unit>
-
insertBefore
public void insertBefore(Chain<E> toInsert, E point)
InsertstoInsertin the Chain beforepoint.- Specified by:
insertBeforein interfaceChain<E extends Unit>
-
insertBefore
public void insertBefore(E toInsert, E point)
InsertstoInsertin the Chain beforepoint.- Specified by:
insertBeforein interfaceChain<E extends Unit>
-
insertBefore
public void insertBefore(Collection<? extends E> toInsert, E point)
Description copied from interface:ChainInsertstoInsertin the Chain beforepoint.- Specified by:
insertBeforein interfaceChain<E extends Unit>
-
insertBeforeNoRedirect
public void insertBeforeNoRedirect(E toInsert, E point)
InsertstoInsertin the Chain beforepointWITHOUT redirecting jumps.
-
insertBeforeNoRedirect
public void insertBeforeNoRedirect(List<E> toInsert, E point)
InsertstoInsertin the Chain beforepointWITHOUT redirecting jumps.
-
remove
public boolean remove(Object obj)
Removes the given object from this Chain.
-
patchBeforeRemoval
protected static <E extends Unit> void patchBeforeRemoval(Chain<E> chain, E removing)
-
contains
public boolean contains(Object u)
Returns true if this patching chain contains the specified element.- Specified by:
containsin interfaceCollection<E extends Unit>- Overrides:
containsin classAbstractCollection<E extends Unit>
-
addFirst
public void addFirst(E u)
Adds the given object at the beginning of the Chain.
-
addLast
public void addLast(E u)
Adds the given object at the end of the Chain.
-
removeFirst
public void removeFirst()
Removes the first object from this Chain.- Specified by:
removeFirstin interfaceChain<E extends Unit>
-
removeLast
public void removeLast()
Removes the last object from this Chain.- Specified by:
removeLastin interfaceChain<E extends Unit>
-
getFirst
public E getFirst()
Returns the first object in this Chain.
-
getLast
public E getLast()
Returns the last object in this Chain.
-
size
public int size()
Returns the size of this Chain.
-
getModificationCount
public long getModificationCount()
Returns the number of times this chain has been modified.- Specified by:
getModificationCountin interfaceChain<E extends Unit>
-
getElementsUnsorted
public Collection<E> getElementsUnsorted()
Description copied from interface:ChainGets all elements in the chain. There is no guarantee on sorting. On the other hand, the collection returned by this method is thread-safe. You can iterate over it even in the case of concurrent modifications to the underlying chain.- Specified by:
getElementsUnsortedin interfaceChain<E extends Unit>- Returns:
- All elements in the chain in an unsorted collection
-
snapshotIterator
public 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!- Specified by:
snapshotIteratorin interfaceChain<E extends Unit>
-
iterator
public Iterator<E> iterator(E u)
Returns an iterator over this Chain, starting at the given object.
-
-