de.lmu.ifi.dbs.elki.database.ids.integer
Class TrivialDBIDFactory

java.lang.Object
  extended by de.lmu.ifi.dbs.elki.database.ids.integer.TrivialDBIDFactory
All Implemented Interfaces:
DBIDFactory

public class TrivialDBIDFactory
extends Object
implements DBIDFactory

Trivial DBID management, that never reuses IDs and just gives them out in sequence. Statically allocated DBID ranges are given positive values, Dynamically allocated DBIDs are given negative values.


Field Summary
(package private)  AtomicInteger next
          Keep track of the smallest dynamic DBID offset not used
 
Fields inherited from interface de.lmu.ifi.dbs.elki.database.ids.DBIDFactory
FACTORY
 
Constructor Summary
TrivialDBIDFactory()
          Constructor
 
Method Summary
 void deallocateDBIDRange(DBIDRange range)
          Deallocate a static DBID range.
 void deallocateSingleDBID(DBID id)
          Return a single DBID for reuse.
 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 an integer ID
 DBIDPair makePair(DBID first, DBID second)
          Make a DBID pair from two existing DBIDs.
 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.
 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.
 TreeSetModifiableDBIDs newTreeSet()
          Make a new (modifiable) tree set of DBIDs.
 TreeSetModifiableDBIDs newTreeSet(DBIDs existing)
          Make a new (modifiable) tree set of DBIDs.
 TreeSetModifiableDBIDs newTreeSet(int size)
          Make a new (modifiable) tree set of DBIDs.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

next

AtomicInteger next
Keep track of the smallest dynamic DBID offset not used

Constructor Detail

TrivialDBIDFactory

public TrivialDBIDFactory()
Constructor

Method Detail

generateSingleDBID

public DBID generateSingleDBID()
Description copied from interface: DBIDFactory
Generate a single DBID

Specified by:
generateSingleDBID in interface DBIDFactory
Returns:
A single DBID

deallocateSingleDBID

public void deallocateSingleDBID(DBID id)
Description copied from interface: DBIDFactory
Return a single DBID for reuse.

Specified by:
deallocateSingleDBID in interface DBIDFactory
Parameters:
id - DBID to deallocate

generateStaticDBIDRange

public DBIDRange generateStaticDBIDRange(int size)
Description copied from interface: DBIDFactory
Generate a static DBID range.

Specified by:
generateStaticDBIDRange in interface DBIDFactory
Parameters:
size - Requested size
Returns:
DBID range

deallocateDBIDRange

public void deallocateDBIDRange(DBIDRange range)
Description copied from interface: DBIDFactory
Deallocate a static DBID range.

Specified by:
deallocateDBIDRange in interface DBIDFactory
Parameters:
range - Range to deallocate

importInteger

public DBID importInteger(int id)
Description copied from interface: DBIDFactory
Import an integer ID

Specified by:
importInteger in interface DBIDFactory
Parameters:
id - Integer ID to import
Returns:
DBID

newArray

public ArrayModifiableDBIDs newArray()
Description copied from interface: DBIDFactory
Make a new (modifiable) array of DBIDs.

Specified by:
newArray in interface DBIDFactory
Returns:
New array

newHashSet

public HashSetModifiableDBIDs newHashSet()
Description copied from interface: DBIDFactory
Make a new (modifiable) hash set of DBIDs.

Specified by:
newHashSet in interface DBIDFactory
Returns:
New hash set

newTreeSet

public TreeSetModifiableDBIDs newTreeSet()
Description copied from interface: DBIDFactory
Make a new (modifiable) tree set of DBIDs.

Specified by:
newTreeSet in interface DBIDFactory
Returns:
New tree set

newArray

public ArrayModifiableDBIDs newArray(int size)
Description copied from interface: DBIDFactory
Make a new (modifiable) array of DBIDs.

Specified by:
newArray in interface DBIDFactory
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 interface DBIDFactory
Parameters:
size - Size hint
Returns:
New hash set

newTreeSet

public TreeSetModifiableDBIDs newTreeSet(int size)
Description copied from interface: DBIDFactory
Make a new (modifiable) tree set of DBIDs.

Specified by:
newTreeSet in interface DBIDFactory
Parameters:
size - Size hint
Returns:
New tree set

newArray

public ArrayModifiableDBIDs newArray(DBIDs existing)
Description copied from interface: DBIDFactory
Make a new (modifiable) array of DBIDs.

Specified by:
newArray in interface DBIDFactory
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 interface DBIDFactory
Parameters:
existing - existing DBIDs to use
Returns:
New hash set

newTreeSet

public TreeSetModifiableDBIDs newTreeSet(DBIDs existing)
Description copied from interface: DBIDFactory
Make a new (modifiable) tree set of DBIDs.

Specified by:
newTreeSet in interface DBIDFactory
Parameters:
existing - existing DBIDs to use
Returns:
New tree set

makePair

public DBIDPair makePair(DBID first,
                         DBID second)
Description copied from interface: DBIDFactory
Make a DBID pair from two existing DBIDs.

Specified by:
makePair in interface DBIDFactory
Parameters:
first - first DBID
second - second DBID
Returns:
new pair.

getDBIDSerializer

public ByteBufferSerializer<DBID> getDBIDSerializer()
Description copied from interface: DBIDFactory
Get a serializer for DBIDs

Specified by:
getDBIDSerializer in interface DBIDFactory
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 interface DBIDFactory
Returns:
DBID serializer

getTypeRestriction

public Class<? extends DBID> getTypeRestriction()
Description copied from interface: DBIDFactory
Get type restriction

Specified by:
getTypeRestriction in interface DBIDFactory
Returns:
type restriction for DBIDs

Release 0.4.0 (2011-09-20_1324)