Package com.ibm.wala.util.intset
Class BasicNaturalRelation
- java.lang.Object
-
- com.ibm.wala.util.intset.BasicNaturalRelation
-
- All Implemented Interfaces:
VerboseAction,IBinaryNaturalRelation,Serializable,Iterable<IntPair>
public final class BasicNaturalRelation extends Object implements IBinaryNaturalRelation, Serializable
A relation between non-negative integersThis implementation uses n IntVectors, to hold the first n y's associated with each x, and then 1 extra vector of SparseIntSet to hold the remaining ys.
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static byteSIMPLETokens used as enumerated types to control the representationstatic byteSIMPLE_SPACE_STINGYstatic byteTWO_LEVEL
-
Constructor Summary
Constructors Constructor Description BasicNaturalRelation()BasicNaturalRelation(byte[] implementation, byte vectorImpl)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanadd(int x, int y)Add (x,y) to the relation.booleananyRelated(int x)booleancontains(int x, int y)IntSetgetRelated(int x)intgetRelatedCount(int x)Iterator<IntPair>iterator()intmaxKeyValue()voidperformVerboseAction()optional method used for performance debuggingvoidremove(int x, int y)voidremoveAll(int x)StringtoString()-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
-
-
-
Field Detail
-
SIMPLE
public static final byte SIMPLE
Tokens used as enumerated types to control the representation- See Also:
- Constant Field Values
-
TWO_LEVEL
public static final byte TWO_LEVEL
- See Also:
- Constant Field Values
-
SIMPLE_SPACE_STINGY
public static final byte SIMPLE_SPACE_STINGY
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
BasicNaturalRelation
public BasicNaturalRelation(byte[] implementation, byte vectorImpl) throws IllegalArgumentException- Parameters:
implementation- a set of codes that represent how the first n IntVectors should be implemented.vectorImpl- a code that indicates how to represent the delegateStore.For example implementation = {SIMPLE_INT_VECTOR,TWO_LEVEL_INT_VECTOR,TWO_LEVEL_INT_VECTOR} will result in an implementation where the first 3 y's associated with each x are represented in IntVectors. The IntVector for the first y will be implemented with a SimpleIntVector, and the 2nd and 3rd are implemented with TwoLevelIntVector
- Throws:
IllegalArgumentException- if implementation is nullIllegalArgumentException- if implementation.length == 0
-
BasicNaturalRelation
public BasicNaturalRelation()
-
-
Method Detail
-
add
@NullUnmarked public boolean add(int x, int y) throws IllegalArgumentExceptionAdd (x,y) to the relation.This is performance-critical, so the implementation looks a little ugly in order to help out the compiler with redundancy elimination.
- Specified by:
addin interfaceIBinaryNaturalRelation- Returns:
- true iff the relation changes as a result of this call.
- Throws:
IllegalArgumentException
-
anyRelated
public boolean anyRelated(int x)
- Specified by:
anyRelatedin interfaceIBinaryNaturalRelation- Returns:
- true iff there exists pair (x,y) for some y
-
getRelated
@NullUnmarked public IntSet getRelated(int x)
- Specified by:
getRelatedin interfaceIBinaryNaturalRelation- Returns:
- IntSet of y s.t. R(x,y) or null if none.
-
getRelatedCount
public int getRelatedCount(int x) throws IllegalArgumentException- Specified by:
getRelatedCountin interfaceIBinaryNaturalRelation- Returns:
- number of y s.t. R(x,y)
- Throws:
IllegalArgumentException
-
remove
public void remove(int x, int y)- Specified by:
removein interfaceIBinaryNaturalRelation
-
removeAll
public void removeAll(int x)
- Specified by:
removeAllin interfaceIBinaryNaturalRelation
-
performVerboseAction
public void performVerboseAction()
Description copied from interface:VerboseActionoptional method used for performance debugging- Specified by:
performVerboseActionin interfaceVerboseAction- See Also:
VerboseAction.performVerboseAction()
-
contains
public boolean contains(int x, int y)- Specified by:
containsin interfaceIBinaryNaturalRelation- Returns:
- true iff (x,y) \in R
-
maxKeyValue
public int maxKeyValue()
- Specified by:
maxKeyValuein interfaceIBinaryNaturalRelation
-
-