public final class TrivialDBIDFactory extends Object implements DBIDFactory
Modifier and Type | Field and Description |
---|---|
(package private) DBID |
invalid
Invalid ID.
|
(package private) AtomicInteger |
next
Keep track of the smallest dynamic DBID offset not used.
|
FACTORY
Constructor and Description |
---|
TrivialDBIDFactory()
Constructor.
|
Modifier and Type | Method and Description |
---|---|
void |
assignVar(DBIDVar var,
int val)
Assign an integer value to a DBID variable.
|
int |
compare(DBIDRef a,
DBIDRef b)
Compare two DBIDs, for sorting.
|
void |
deallocateDBIDRange(DBIDRange range)
Deallocate a static DBID range.
|
void |
deallocateSingleDBID(DBIDRef id)
Return a single DBID for reuse.
|
boolean |
equal(DBIDRef a,
DBIDRef b)
Compare two DBIDs, for equality testing.
|
DBID |
generateSingleDBID()
Generate a single DBID.
|
DBIDRange |
generateStaticDBIDRange(int size)
Generate a static DBID range.
|
ByteBufferSerializer<DBID> |
getDBIDSerializer()
Get a serializer for DBIDs.
|
FixedSizeByteBufferSerializer<DBID> |
getDBIDSerializerStatic()
Get a serializer for DBIDs with static size.
|
Class<? extends DBID> |
getTypeRestriction()
Get type restriction.
|
DBID |
importInteger(int id)
Import and integer as DBID.
|
DBIDRef |
invalid()
Get the invalid DBID value, usable as "undefined" placeholder.
|
ArrayModifiableDBIDs |
newArray()
Make a new (modifiable) array of DBIDs.
|
ArrayModifiableDBIDs |
newArray(DBIDs existing)
Make a new (modifiable) array of DBIDs.
|
ArrayModifiableDBIDs |
newArray(int size)
Make a new (modifiable) array of DBIDs.
|
<D extends Distance<D>> |
newDistancePair(D val,
DBIDRef id)
Make a new distance-DBID pair.
|
DoubleDistanceDBIDPair |
newDistancePair(double val,
DBIDRef id)
Make a new distance-DBID pair.
|
HashSetModifiableDBIDs |
newHashSet()
Make a new (modifiable) hash set of DBIDs.
|
HashSetModifiableDBIDs |
newHashSet(DBIDs existing)
Make a new (modifiable) hash set of DBIDs.
|
HashSetModifiableDBIDs |
newHashSet(int size)
Make a new (modifiable) hash set of DBIDs.
|
DBIDPair |
newPair(DBIDRef first,
DBIDRef second)
Make a DBID pair from two existing DBIDs.
|
DoubleDBIDPair |
newPair(double val,
DBIDRef id)
Make a double-DBID pair.
|
DBIDVar |
newVar(DBIDRef val)
Make a new DBID variable.
|
String |
toString(DBIDRef id)
Print a DBID as string.
|
AtomicInteger next
DBID invalid
public final DBID generateSingleDBID()
DBIDFactory
generateSingleDBID
in interface DBIDFactory
public final void deallocateSingleDBID(DBIDRef id)
DBIDFactory
deallocateSingleDBID
in interface DBIDFactory
id
- DBID to deallocatepublic final DBIDRange generateStaticDBIDRange(int size)
DBIDFactory
generateStaticDBIDRange
in interface DBIDFactory
size
- Requested sizepublic void deallocateDBIDRange(DBIDRange range)
DBIDFactory
deallocateDBIDRange
in interface DBIDFactory
range
- Range to deallocatepublic DBID importInteger(int id)
DBIDFactory
importInteger
in interface DBIDFactory
id
- Integer ID to importpublic void assignVar(DBIDVar var, int val)
DBIDFactory
assignVar
in interface DBIDFactory
var
- Variableval
- Integer valuepublic int compare(DBIDRef a, DBIDRef b)
DBIDFactory
compare
in interface DBIDFactory
a
- Firstb
- Secondpublic boolean equal(DBIDRef a, DBIDRef b)
DBIDFactory
equal
in interface DBIDFactory
a
- Firstb
- Secondpublic String toString(DBIDRef id)
DBIDFactory
toString
in interface DBIDFactory
id
- DBID referencepublic DBIDVar newVar(DBIDRef val)
DBIDFactory
newVar
in interface DBIDFactory
val
- Initial value.public ArrayModifiableDBIDs newArray()
DBIDFactory
newArray
in interface DBIDFactory
public HashSetModifiableDBIDs newHashSet()
DBIDFactory
newHashSet
in interface DBIDFactory
public ArrayModifiableDBIDs newArray(int size)
DBIDFactory
newArray
in interface DBIDFactory
size
- Size hintpublic HashSetModifiableDBIDs newHashSet(int size)
DBIDFactory
newHashSet
in interface DBIDFactory
size
- Size hintpublic ArrayModifiableDBIDs newArray(DBIDs existing)
DBIDFactory
newArray
in interface DBIDFactory
existing
- existing DBIDs to usepublic HashSetModifiableDBIDs newHashSet(DBIDs existing)
DBIDFactory
newHashSet
in interface DBIDFactory
existing
- existing DBIDs to usepublic DBIDPair newPair(DBIDRef first, DBIDRef second)
DBIDFactory
newPair
in interface DBIDFactory
first
- first DBIDsecond
- second DBIDpublic DoubleDBIDPair newPair(double val, DBIDRef id)
DBIDFactory
newPair
in interface DBIDFactory
val
- Double valueid
- DBIDpublic <D extends Distance<D>> DistanceDBIDPair<D> newDistancePair(D val, DBIDRef id)
DBIDFactory
newDistancePair
in interface DBIDFactory
D
- Distance typeval
- Distance valueid
- Object IDpublic DoubleDistanceDBIDPair newDistancePair(double val, DBIDRef id)
DBIDFactory
newDistancePair
in interface DBIDFactory
val
- Distance valueid
- Object IDpublic ByteBufferSerializer<DBID> getDBIDSerializer()
DBIDFactory
getDBIDSerializer
in interface DBIDFactory
public FixedSizeByteBufferSerializer<DBID> getDBIDSerializerStatic()
DBIDFactory
getDBIDSerializerStatic
in interface DBIDFactory
public Class<? extends DBID> getTypeRestriction()
DBIDFactory
getTypeRestriction
in interface DBIDFactory
public DBIDRef invalid()
DBIDFactory
invalid
in interface DBIDFactory