Package elki.database.ids.integer
Class AbstractIntegerDBIDFactory
- java.lang.Object
-
- elki.database.ids.integer.AbstractIntegerDBIDFactory
-
- All Implemented Interfaces:
DBIDFactory
- Direct Known Subclasses:
TrivialDBIDFactory
abstract class AbstractIntegerDBIDFactory extends java.lang.Object implements DBIDFactory
Abstract base class for DBID factories.- Since:
- 0.4.0
- Author:
- Erich Schubert
-
-
Field Summary
Fields Modifier and Type Field Description (package private) DBID
invalid
Invalid ID.-
Fields inherited from interface elki.database.ids.DBIDFactory
FACTORY
-
-
Constructor Summary
Constructors Constructor Description AbstractIntegerDBIDFactory()
-
Method Summary
All Methods Instance Methods Concrete 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.boolean
equal(DBIDRef a, DBIDRef b)
Compare two DBIDs, for equality testing.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 alsoDBIDFactory.newHeap(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 first, DBIDRef second)
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.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface elki.database.ids.DBIDFactory
deallocateDBIDRange, deallocateSingleDBID, generateSingleDBID, generateStaticDBIDRange, generateStaticDBIDRange
-
-
-
-
Field Detail
-
invalid
DBID invalid
Invalid ID.
-
-
Method Detail
-
importInteger
public DBID importInteger(int id)
Description copied from interface:DBIDFactory
Import and integer as DBID.Note: this may not be possible for some factories that are not int-based!
- Specified by:
importInteger
in interfaceDBIDFactory
- Parameters:
id
- Integer ID to import- Returns:
- DBID
-
assignVar
public DBIDVar assignVar(DBIDVar var, int val)
Description copied from interface:DBIDFactory
Assign an integer value to a DBID variable.Note: this may not be possible for some factories that are not int-based!
- Specified by:
assignVar
in interfaceDBIDFactory
- Parameters:
var
- Variableval
- Integer value
-
compare
public int compare(DBIDRef a, DBIDRef b)
Description copied from interface:DBIDFactory
Compare two DBIDs, for sorting.- Specified by:
compare
in interfaceDBIDFactory
- Parameters:
a
- Firstb
- Second- Returns:
- Comparison result
-
equal
public boolean equal(DBIDRef a, DBIDRef b)
Description copied from interface:DBIDFactory
Compare two DBIDs, for equality testing.- Specified by:
equal
in interfaceDBIDFactory
- Parameters:
a
- Firstb
- Second- Returns:
- Comparison result
-
toString
public java.lang.String toString(DBIDRef id)
Description copied from interface:DBIDFactory
Print a DBID as string.- Specified by:
toString
in interfaceDBIDFactory
- Parameters:
id
- DBID reference- Returns:
- Formatted ID
-
newVar
public DBIDVar newVar(DBIDRef val)
Description copied from interface:DBIDFactory
Make a new DBID variable.- Specified by:
newVar
in interfaceDBIDFactory
- Parameters:
val
- Initial value.- Returns:
- Variable
-
newArray
public ArrayModifiableDBIDs newArray()
Description copied from interface:DBIDFactory
Make a new (modifiable) array of DBIDs.- Specified by:
newArray
in interfaceDBIDFactory
- Returns:
- New array
-
newHashSet
public HashSetModifiableDBIDs newHashSet()
Description copied from interface:DBIDFactory
Make a new (modifiable) hash set of DBIDs.- Specified by:
newHashSet
in interfaceDBIDFactory
- Returns:
- New hash set
-
newArray
public ArrayModifiableDBIDs newArray(int size)
Description copied from interface:DBIDFactory
Make a new (modifiable) array of DBIDs.- Specified by:
newArray
in interfaceDBIDFactory
- Parameters:
size
- Size hint- Returns:
- New array
-
newHashSet
public HashSetModifiableDBIDs newHashSet(int size)
Description copied from interface:DBIDFactory
Make a new (modifiable) hash set of DBIDs.- Specified by:
newHashSet
in interfaceDBIDFactory
- Parameters:
size
- Size hint- Returns:
- New hash set
-
newArray
public ArrayModifiableDBIDs newArray(DBIDs existing)
Description copied from interface:DBIDFactory
Make a new (modifiable) array of DBIDs.- Specified by:
newArray
in interfaceDBIDFactory
- Parameters:
existing
- existing DBIDs to use- Returns:
- New array
-
newHashSet
public HashSetModifiableDBIDs newHashSet(DBIDs existing)
Description copied from interface:DBIDFactory
Make a new (modifiable) hash set of DBIDs.- Specified by:
newHashSet
in interfaceDBIDFactory
- Parameters:
existing
- existing DBIDs to use- Returns:
- New hash set
-
newPair
public DBIDPair newPair(DBIDRef first, DBIDRef second)
Description copied from interface:DBIDFactory
Make a DBID pair from two existing DBIDs.- Specified by:
newPair
in interfaceDBIDFactory
- Parameters:
first
- first DBIDsecond
- second DBID- Returns:
- new pair.
-
newPair
public DoubleDBIDPair newPair(double val, DBIDRef id)
Description copied from interface:DBIDFactory
Make a double-DBID pair.- Specified by:
newPair
in interfaceDBIDFactory
- Parameters:
val
- Double valueid
- DBID- Returns:
- New pair
-
newMinHeap
public DoubleDBIDHeap newMinHeap(int k)
Description copied from interface:DBIDFactory
Create a min heap.- Specified by:
newMinHeap
in interfaceDBIDFactory
- Parameters:
k
- Design sign- Returns:
- New heap of size k.
-
newMaxHeap
public DoubleDBIDHeap newMaxHeap(int k)
Description copied from interface:DBIDFactory
Create a max heap (see alsoDBIDFactory.newHeap(int)
for a kNN heap).- Specified by:
newMaxHeap
in interfaceDBIDFactory
- Parameters:
k
- Design sign- Returns:
- New heap of size k.
-
newHeap
public KNNHeap newHeap(int k)
Description copied from interface:DBIDFactory
Create an heap for kNN search.- Specified by:
newHeap
in interfaceDBIDFactory
- Parameters:
k
- K value- Returns:
- New heap of size k.
-
newHeap
public KNNHeap newHeap(KNNList exist)
Description copied from interface:DBIDFactory
Build a new heap from a given list.- Specified by:
newHeap
in interfaceDBIDFactory
- Parameters:
exist
- Existing result- Returns:
- New heap
-
newDistanceDBIDList
public ModifiableDoubleDBIDList newDistanceDBIDList(int size)
Description copied from interface:DBIDFactory
Create a modifiable list to store distance-DBID pairs.- Specified by:
newDistanceDBIDList
in interfaceDBIDFactory
- Parameters:
size
- initial size estimate- Returns:
- New list of given initial size
-
newDistanceDBIDList
public ModifiableDoubleDBIDList newDistanceDBIDList()
Description copied from interface:DBIDFactory
Create a modifiable list to store distance-DBID pairs.- Specified by:
newDistanceDBIDList
in interfaceDBIDFactory
- Returns:
- New list
-
makeUnmodifiable
public StaticDBIDs makeUnmodifiable(DBIDs existing)
Description copied from interface:DBIDFactory
Make DBIDs immutable.- Specified by:
makeUnmodifiable
in interfaceDBIDFactory
- Parameters:
existing
- Existing DBIDs- Returns:
- Immutable version
-
getDBIDSerializer
public ByteBufferSerializer<DBID> getDBIDSerializer()
Description copied from interface:DBIDFactory
Get a serializer for DBIDs.- Specified by:
getDBIDSerializer
in interfaceDBIDFactory
- Returns:
- DBID serializer
-
getDBIDSerializerStatic
public FixedSizeByteBufferSerializer<DBID> getDBIDSerializerStatic()
Description copied from interface:DBIDFactory
Get a serializer for DBIDs with static size.- Specified by:
getDBIDSerializerStatic
in interfaceDBIDFactory
- Returns:
- DBID serializer
-
getTypeRestriction
public java.lang.Class<? extends DBID> getTypeRestriction()
Description copied from interface:DBIDFactory
Get type restriction.- Specified by:
getTypeRestriction
in interfaceDBIDFactory
- Returns:
- type restriction for DBIDs
-
invalid
public DBIDRef invalid()
Description copied from interface:DBIDFactory
Get the invalid DBID value, usable as "undefined" placeholder.- Specified by:
invalid
in interfaceDBIDFactory
- Returns:
- Invalid value
-
-