de.lmu.ifi.dbs.elki.database.ids
Class DBIDUtil

java.lang.Object
  extended by de.lmu.ifi.dbs.elki.database.ids.DBIDUtil

public final class DBIDUtil
extends Object

DBID Utility functions.


Field Summary
static EmptyDBIDs EMPTYDBIDS
          Final, global copy of empty DBIDs.
 
Constructor Summary
private DBIDUtil()
          Static - no public constructor.
 
Method Summary
static void deallocateDBIDRange(DBIDRange range)
          Deallocate a static DBID range.
static void deallocateSingleDBID(DBID id)
          Return a single DBID for reuse.
static ModifiableDBIDs difference(DBIDs ids1, DBIDs ids2)
          Returns the difference of the two specified collection of IDs.
static ArrayDBIDs ensureArray(DBIDs ids)
          Ensure that the given DBIDs are array-indexable.
static ModifiableDBIDs ensureModifiable(DBIDs ids)
          Ensure modifiable
static SetDBIDs ensureSet(DBIDs ids)
          Ensure that the given DBIDs support fast "contains" operations.
static DBID generateSingleDBID()
          Generate a single DBID
static DBIDRange generateStaticDBIDRange(int size)
          Generate a static DBID range.
 ByteBufferSerializer<DBID> getDBIDSerializer()
          Get a serializer for DBIDs
 ByteBufferSerializer<DBID> getDBIDSerializerStatic()
          Get a serializer for DBIDs with static size
static DBID importInteger(int id)
          Import an Integer DBID.
static ModifiableDBIDs intersection(DBIDs first, DBIDs second)
          Compute the set intersection of two sets.
static StaticDBIDs makeUnmodifiable(DBIDs existing)
          Wrap an existing DBIDs collection to be unmodifiable.
static ArrayModifiableDBIDs newArray()
          Make a new (modifiable) array of DBIDs.
static ArrayModifiableDBIDs newArray(DBIDs existing)
          Make a new (modifiable) array of DBIDs.
static ArrayModifiableDBIDs newArray(int size)
          Make a new (modifiable) array of DBIDs.
static HashSetModifiableDBIDs newHashSet()
          Make a new (modifiable) hash set of DBIDs.
static HashSetModifiableDBIDs newHashSet(DBIDs existing)
          Make a new (modifiable) hash set of DBIDs.
static HashSetModifiableDBIDs newHashSet(int size)
          Make a new (modifiable) hash set of DBIDs.
static DBIDPair newPair(DBID id1, DBID id2)
          Make a DBID pair.
static TreeSetModifiableDBIDs newTreeSet()
          Make a new (modifiable) tree set of DBIDs.
static TreeSetModifiableDBIDs newTreeSet(DBIDs existing)
          Make a new (modifiable) tree set of DBIDs.
static TreeSetModifiableDBIDs newTreeSet(int size)
          Make a new (modifiable) tree set of DBIDs.
static ModifiableDBIDs randomSample(DBIDs source, int k, long seed)
          Produce a random sample of the given DBIDs
static ModifiableDBIDs union(DBIDs ids1, DBIDs ids2)
          Returns the union of the two specified collection of IDs.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

EMPTYDBIDS

public static final EmptyDBIDs EMPTYDBIDS
Final, global copy of empty DBIDs.

Constructor Detail

DBIDUtil

private DBIDUtil()
Static - no public constructor.

Method Detail

importInteger

public static DBID importInteger(int id)
Import an Integer DBID.

Parameters:
id - Integer ID
Returns:
DBID

getDBIDSerializer

public ByteBufferSerializer<DBID> getDBIDSerializer()
Get a serializer for DBIDs

Returns:
DBID serializer

getDBIDSerializerStatic

public ByteBufferSerializer<DBID> getDBIDSerializerStatic()
Get a serializer for DBIDs with static size

Returns:
DBID serializer

generateSingleDBID

public static DBID generateSingleDBID()
Generate a single DBID

Returns:
A single DBID

deallocateSingleDBID

public static void deallocateSingleDBID(DBID id)
Return a single DBID for reuse.

Parameters:
id - DBID to deallocate

generateStaticDBIDRange

public static DBIDRange generateStaticDBIDRange(int size)
Generate a static DBID range.

Parameters:
size - Requested size
Returns:
DBID range

deallocateDBIDRange

public static void deallocateDBIDRange(DBIDRange range)
Deallocate a static DBID range.

Parameters:
range - Range to deallocate

newArray

public static ArrayModifiableDBIDs newArray()
Make a new (modifiable) array of DBIDs.

Returns:
New array

newHashSet

public static HashSetModifiableDBIDs newHashSet()
Make a new (modifiable) hash set of DBIDs.

Returns:
New hash set

newTreeSet

public static TreeSetModifiableDBIDs newTreeSet()
Make a new (modifiable) tree set of DBIDs.

Returns:
New tree set

newArray

public static ArrayModifiableDBIDs newArray(int size)
Make a new (modifiable) array of DBIDs.

Parameters:
size - Size hint
Returns:
New array

newHashSet

public static HashSetModifiableDBIDs newHashSet(int size)
Make a new (modifiable) hash set of DBIDs.

Parameters:
size - Size hint
Returns:
New hash set

newTreeSet

public static TreeSetModifiableDBIDs newTreeSet(int size)
Make a new (modifiable) tree set of DBIDs.

Parameters:
size - Size hint
Returns:
New tree set

newArray

public static ArrayModifiableDBIDs newArray(DBIDs existing)
Make a new (modifiable) array of DBIDs.

Parameters:
existing - Existing DBIDs
Returns:
New array

newHashSet

public static HashSetModifiableDBIDs newHashSet(DBIDs existing)
Make a new (modifiable) hash set of DBIDs.

Parameters:
existing - Existing DBIDs
Returns:
New hash set

newTreeSet

public static TreeSetModifiableDBIDs newTreeSet(DBIDs existing)
Make a new (modifiable) tree set of DBIDs.

Parameters:
existing - Existing DBIDs
Returns:
New tree set

intersection

public static ModifiableDBIDs intersection(DBIDs first,
                                           DBIDs second)
Compute the set intersection of two sets.

Parameters:
first - First set
second - Second set
Returns:
result.

union

public static ModifiableDBIDs union(DBIDs ids1,
                                    DBIDs ids2)
Returns the union of the two specified collection of IDs.

Parameters:
ids1 - the first collection
ids2 - the second collection
Returns:
the union of ids1 and ids2 without duplicates

difference

public static ModifiableDBIDs difference(DBIDs ids1,
                                         DBIDs ids2)
Returns the difference of the two specified collection of IDs.

Parameters:
ids1 - the first collection
ids2 - the second collection
Returns:
the difference of ids1 minus ids2

makeUnmodifiable

public static StaticDBIDs makeUnmodifiable(DBIDs existing)
Wrap an existing DBIDs collection to be unmodifiable.

Parameters:
existing - Existing collection
Returns:
Unmodifiable collection

ensureArray

public static ArrayDBIDs ensureArray(DBIDs ids)
Ensure that the given DBIDs are array-indexable.

Parameters:
ids -
Returns:
Array DBIDs.

ensureSet

public static SetDBIDs ensureSet(DBIDs ids)
Ensure that the given DBIDs support fast "contains" operations.

Parameters:
ids -
Returns:
Array DBIDs.

ensureModifiable

public static ModifiableDBIDs ensureModifiable(DBIDs ids)
Ensure modifiable

Parameters:
ids -
Returns:
Array DBIDs.

newPair

public static DBIDPair newPair(DBID id1,
                               DBID id2)
Make a DBID pair.

Parameters:
id1 - first ID
id2 - second ID
Returns:
DBID pair

randomSample

public static ModifiableDBIDs randomSample(DBIDs source,
                                           int k,
                                           long seed)
Produce a random sample of the given DBIDs

Parameters:
source - Original DBIDs
k - k Parameter
seed - Random generator seed
Returns:
new DBIDs

Release 0.4.0 (2011-09-20_1324)