Package elki.database.ids
Interface DBIDFactory
-
- All Known Implementing Classes:
AbstractIntegerDBIDFactory
,TrivialDBIDFactory
public interface DBIDFactory
Factory interface for generating DBIDs. SeeFACTORY
for the static instance to use.- Since:
- 0.4.0
- Author:
- Erich Schubert
-
-
Field Summary
Fields Modifier and Type Field Description static DBIDFactory
FACTORY
Static DBID factory to use.
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description DBIDVar
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.DBIDRange
generateStaticDBIDRange(int begin, 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.java.lang.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.StaticDBIDs
makeUnmodifiable(DBIDs existing)
Make DBIDs immutable.ArrayModifiableDBIDs
newArray()
Make a new (modifiable) array of DBIDs.ArrayModifiableDBIDs
newArray(int size)
Make a new (modifiable) array of DBIDs.ArrayModifiableDBIDs
newArray(DBIDs existing)
Make a new (modifiable) array of DBIDs.ModifiableDoubleDBIDList
newDistanceDBIDList()
Create a modifiable list to store distance-DBID pairs.ModifiableDoubleDBIDList
newDistanceDBIDList(int size)
Create a modifiable list to store distance-DBID pairs.HashSetModifiableDBIDs
newHashSet()
Make a new (modifiable) hash set of DBIDs.HashSetModifiableDBIDs
newHashSet(int size)
Make a new (modifiable) hash set of DBIDs.HashSetModifiableDBIDs
newHashSet(DBIDs existing)
Make a new (modifiable) hash set of DBIDs.KNNHeap
newHeap(int k)
Create an heap for kNN search.KNNHeap
newHeap(KNNList exist)
Build a new heap from a given list.DoubleDBIDHeap
newMaxHeap(int k)
Create a max heap (see alsonewHeap(int)
for a kNN heap).DoubleDBIDHeap
newMinHeap(int k)
Create a min heap.DoubleDBIDPair
newPair(double val, DBIDRef id)
Make a double-DBID pair.DBIDPair
newPair(DBIDRef id1, DBIDRef id2)
Make a DBID pair from two existing DBIDs.DBIDVar
newVar(DBIDRef val)
Make a new DBID variable.java.lang.String
toString(DBIDRef id)
Print a DBID as string.
-
-
-
Field Detail
-
FACTORY
static final DBIDFactory FACTORY
Static DBID factory to use.
-
-
Method Detail
-
newVar
DBIDVar newVar(DBIDRef val)
Make a new DBID variable.- Parameters:
val
- Initial value.- Returns:
- Variable
-
importInteger
DBID importInteger(int id)
Import and integer as DBID.Note: this may not be possible for some factories that are not int-based!
- Parameters:
id
- Integer ID to import- Returns:
- DBID
-
assignVar
DBIDVar assignVar(DBIDVar var, int val)
Assign an integer value to a DBID variable.Note: this may not be possible for some factories that are not int-based!
- Parameters:
var
- Variableval
- Integer value
-
generateSingleDBID
DBID generateSingleDBID()
Generate a single DBID.- Returns:
- A single DBID
-
deallocateSingleDBID
void deallocateSingleDBID(DBIDRef id)
Return a single DBID for reuse.- Parameters:
id
- DBID to deallocate
-
generateStaticDBIDRange
DBIDRange generateStaticDBIDRange(int size)
Generate a static DBID range.- Parameters:
size
- Requested size- Returns:
- DBID range
-
generateStaticDBIDRange
DBIDRange generateStaticDBIDRange(int begin, int size)
Generate a static DBID range.- Parameters:
begin
- Range beginsize
- Requested size- Returns:
- DBID range
-
deallocateDBIDRange
void deallocateDBIDRange(DBIDRange range)
Deallocate a static DBID range.- Parameters:
range
- Range to deallocate
-
newPair
DBIDPair newPair(DBIDRef id1, DBIDRef id2)
Make a DBID pair from two existing DBIDs.- Parameters:
id1
- first DBIDid2
- second DBID- Returns:
- new pair.
-
newPair
DoubleDBIDPair newPair(double val, DBIDRef id)
Make a double-DBID pair.- Parameters:
val
- Double valueid
- DBID- Returns:
- New pair
-
newArray
ArrayModifiableDBIDs newArray()
Make a new (modifiable) array of DBIDs.- Returns:
- New array
-
newHashSet
HashSetModifiableDBIDs newHashSet()
Make a new (modifiable) hash set of DBIDs.- Returns:
- New hash set
-
newArray
ArrayModifiableDBIDs newArray(int size)
Make a new (modifiable) array of DBIDs.- Parameters:
size
- Size hint- Returns:
- New array
-
newHashSet
HashSetModifiableDBIDs newHashSet(int size)
Make a new (modifiable) hash set of DBIDs.- Parameters:
size
- Size hint- Returns:
- New hash set
-
newArray
ArrayModifiableDBIDs newArray(DBIDs existing)
Make a new (modifiable) array of DBIDs.- Parameters:
existing
- existing DBIDs to use- Returns:
- New array
-
newHashSet
HashSetModifiableDBIDs newHashSet(DBIDs existing)
Make a new (modifiable) hash set of DBIDs.- Parameters:
existing
- existing DBIDs to use- Returns:
- New hash set
-
newMinHeap
DoubleDBIDHeap newMinHeap(int k)
Create a min heap.- Parameters:
k
- Design sign- Returns:
- New heap of size k.
-
newMaxHeap
DoubleDBIDHeap newMaxHeap(int k)
Create a max heap (see alsonewHeap(int)
for a kNN heap).- Parameters:
k
- Design sign- Returns:
- New heap of size k.
-
newHeap
KNNHeap newHeap(int k)
Create an heap for kNN search.- Parameters:
k
- K value- Returns:
- New heap of size k.
-
newHeap
KNNHeap newHeap(KNNList exist)
Build a new heap from a given list.- Parameters:
exist
- Existing result- Returns:
- New heap
-
getDBIDSerializer
ByteBufferSerializer<DBID> getDBIDSerializer()
Get a serializer for DBIDs.- Returns:
- DBID serializer
-
getDBIDSerializerStatic
FixedSizeByteBufferSerializer<DBID> getDBIDSerializerStatic()
Get a serializer for DBIDs with static size.- Returns:
- DBID serializer
-
getTypeRestriction
java.lang.Class<? extends DBID> getTypeRestriction()
Get type restriction.- Returns:
- type restriction for DBIDs
-
compare
int compare(DBIDRef a, DBIDRef b)
Compare two DBIDs, for sorting.- Parameters:
a
- Firstb
- Second- Returns:
- Comparison result
-
equal
boolean equal(DBIDRef a, DBIDRef b)
Compare two DBIDs, for equality testing.- Parameters:
a
- Firstb
- Second- Returns:
- Comparison result
-
toString
java.lang.String toString(DBIDRef id)
Print a DBID as string.- Parameters:
id
- DBID reference- Returns:
- Formatted ID
-
invalid
DBIDRef invalid()
Get the invalid DBID value, usable as "undefined" placeholder.- Returns:
- Invalid value
-
newDistanceDBIDList
ModifiableDoubleDBIDList newDistanceDBIDList(int size)
Create a modifiable list to store distance-DBID pairs.- Parameters:
size
- initial size estimate- Returns:
- New list of given initial size
-
newDistanceDBIDList
ModifiableDoubleDBIDList newDistanceDBIDList()
Create a modifiable list to store distance-DBID pairs.- Returns:
- New list
-
makeUnmodifiable
StaticDBIDs makeUnmodifiable(DBIDs existing)
Make DBIDs immutable.- Parameters:
existing
- Existing DBIDs- Returns:
- Immutable version
-
-