public final class BasicNaturalRelation extends Object implements IBinaryNaturalRelation, Serializable
This 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.
| Modifier and Type | Field and Description |
|---|---|
static byte |
SIMPLE
Tokens used as enumerated types to control the representation
|
static byte |
SIMPLE_SPACE_STINGY |
static byte |
TWO_LEVEL |
| Constructor and Description |
|---|
BasicNaturalRelation() |
BasicNaturalRelation(byte[] implementation,
byte vectorImpl) |
| Modifier and Type | Method and Description |
|---|---|
boolean |
add(int x,
int y)
Add (x,y) to the relation.
|
boolean |
anyRelated(int x) |
boolean |
contains(int x,
int y) |
IntSet |
getRelated(int x) |
int |
getRelatedCount(int x) |
Iterator<IntPair> |
iterator() |
int |
maxKeyValue() |
void |
performVerboseAction()
optional method used for performance debugging
|
void |
remove(int x,
int y) |
void |
removeAll(int x) |
String |
toString() |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitforEach, spliteratorpublic static final byte SIMPLE
public static final byte TWO_LEVEL
public static final byte SIMPLE_SPACE_STINGY
public BasicNaturalRelation(byte[] implementation,
byte vectorImpl)
throws IllegalArgumentException
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
IllegalArgumentException - if implementation is nullIllegalArgumentException - if implementation.length == 0public BasicNaturalRelation()
public boolean add(int x,
int y)
throws IllegalArgumentException
This is performance-critical, so the implementation looks a little ugly in order to help out the compiler with redundancy elimination.
add in interface IBinaryNaturalRelationIllegalArgumentExceptionpublic boolean anyRelated(int x)
anyRelated in interface IBinaryNaturalRelationpublic IntSet getRelated(int x)
getRelated in interface IBinaryNaturalRelationpublic int getRelatedCount(int x)
throws IllegalArgumentException
getRelatedCount in interface IBinaryNaturalRelationIllegalArgumentExceptionpublic void remove(int x,
int y)
remove in interface IBinaryNaturalRelationpublic void removeAll(int x)
removeAll in interface IBinaryNaturalRelationpublic void performVerboseAction()
VerboseActionperformVerboseAction in interface VerboseActionpublic boolean contains(int x,
int y)
contains in interface IBinaryNaturalRelationpublic int maxKeyValue()
maxKeyValue in interface IBinaryNaturalRelation