public final class DBIDUtil extends Object
Modifier and Type | Field and Description |
---|---|
static EmptyDBIDs |
EMPTYDBIDS
Final, global copy of empty DBIDs.
|
Modifier | Constructor and Description |
---|---|
private |
DBIDUtil()
Static - no public constructor.
|
Modifier and Type | Method and Description |
---|---|
static int |
asInteger(DBIDRef id)
Export a DBID as int.
|
static DBIDRange |
assertRange(DBIDs ids)
Assert that the presented ids constitute a continuous
DBIDRange . |
static int |
compare(DBIDRef id1,
DBIDRef id2)
Compare two DBIDs.
|
static void |
deallocateDBIDRange(DBIDRange range)
Deallocate a static DBID range.
|
static void |
deallocateSingleDBID(DBID id)
Return a single DBID for reuse.
|
static DBID |
deref(DBIDRef ref)
Dereference a DBID reference.
|
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 boolean |
equal(DBIDRef id1,
DBIDRef id2)
Test two DBIDs for equality.
|
static DBID |
generateSingleDBID()
Generate a single DBID.
|
static DBIDRange |
generateStaticDBIDRange(int size)
Generate a static DBID range.
|
static ByteBufferSerializer<DBID> |
getDBIDSerializer()
Get a serializer for DBIDs.
|
static ByteBufferSerializer<DBID> |
getDBIDSerializerStatic()
Get a serializer for DBIDs with static size.
|
static DBID |
importInteger(int id)
Import and integer as DBID.
|
private static int |
internalIntersectionSize(DBIDs first,
DBIDs second)
Compute the set intersection size of two sets.
|
static ModifiableDBIDs |
intersection(DBIDs first,
DBIDs second)
Compute the set intersection of two sets.
|
static int |
intersectionSize(DBIDs first,
DBIDs second)
Compute the set intersection size of two sets.
|
static DBIDRef |
invalid()
Get the invalid special ID.
|
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 ModifiableDoubleDBIDList |
newDistanceDBIDList()
Create a modifiable list to store distance-DBID pairs.
|
static ModifiableDoubleDBIDList |
newDistanceDBIDList(int size)
Create a modifiable list to store distance-DBID pairs.
|
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 KNNHeap |
newHeap(int k)
Create an appropriate heap for the distance type.
|
static KNNHeap |
newHeap(KNNList exist)
Build a new heap from a given list.
|
static DBIDPair |
newPair(DBIDRef id1,
DBIDRef id2)
Make a DBID pair.
|
static DoubleDBIDPair |
newPair(double val,
DBIDRef id)
Make a DoubleDBIDPair.
|
static DBIDVar |
newVar()
Make a new DBID variable.
|
static DBIDVar |
newVar(DBIDRef val)
Make a new DBID variable.
|
static DBIDs |
randomSample(DBIDs ids,
double rate,
Random random)
Produce a random sample of the given DBIDs.
|
static DBIDs |
randomSample(DBIDs ids,
double rate,
RandomFactory random)
Produce a random sample of the given DBIDs.
|
static ModifiableDBIDs |
randomSample(DBIDs source,
int k,
int seed)
Produce a random sample of the given DBIDs.
|
static ModifiableDBIDs |
randomSample(DBIDs source,
int k,
Long seed)
Produce a random sample of the given DBIDs.
|
static ModifiableDBIDs |
randomSample(DBIDs source,
int k,
Random random)
Produce a random sample of the given DBIDs.
|
static ModifiableDBIDs |
randomSample(DBIDs source,
int k,
RandomFactory rnd)
Produce a random sample of the given DBIDs.
|
static DBIDVar |
randomSample(DBIDs ids,
Random random)
Draw a single random sample.
|
static DBIDVar |
randomSample(DBIDs ids,
RandomFactory random)
Draw a single random sample.
|
static void |
randomShuffle(ArrayModifiableDBIDs ids,
Random random)
Produce a random shuffling of the given DBID array.
|
static void |
randomShuffle(ArrayModifiableDBIDs ids,
RandomFactory rnd)
Produce a random shuffling of the given DBID array.
|
static void |
randomShuffle(ArrayModifiableDBIDs ids,
Random random,
int limit)
Produce a random shuffling of the given DBID array.
|
static ArrayDBIDs[] |
randomSplit(DBIDs oids,
int p,
Random random)
Randomly split IDs into
p partitions of almost-equal size. |
static ArrayDBIDs[] |
randomSplit(DBIDs ids,
int p,
RandomFactory rnd)
Randomly split IDs into
p partitions of almost-equal size. |
static KNNList |
subList(KNNList list,
int k)
Get a subset of the KNN result.
|
static void |
symmetricIntersection(DBIDs first,
DBIDs second,
HashSetModifiableDBIDs firstonly,
HashSetModifiableDBIDs intersection,
HashSetModifiableDBIDs secondonly)
Compute the set symmetric intersection of two sets.
|
static String |
toString(DBIDRef id)
Format a DBID as string.
|
static String |
toString(DBIDs ids)
Format a DBID as string.
|
static ModifiableDBIDs |
union(DBIDs ids1,
DBIDs ids2)
Returns the union of the two specified collection of IDs.
|
public static final EmptyDBIDs EMPTYDBIDS
public static DBIDRef invalid()
public static DBID importInteger(int id)
id
- Integer ID to importpublic static int asInteger(DBIDRef id)
id
- DBID to exportpublic static int compare(DBIDRef id1, DBIDRef id2)
id1
- First IDid2
- Second IDpublic static boolean equal(DBIDRef id1, DBIDRef id2)
id1
- First IDid2
- Second IDpublic static DBID deref(DBIDRef ref)
ref
- DBID referencepublic static String toString(DBIDRef id)
id
- DBIDpublic static String toString(DBIDs ids)
ids
- DBIDspublic static ByteBufferSerializer<DBID> getDBIDSerializer()
public static ByteBufferSerializer<DBID> getDBIDSerializerStatic()
public static DBID generateSingleDBID()
public static void deallocateSingleDBID(DBID id)
id
- DBID to deallocatepublic static DBIDRange generateStaticDBIDRange(int size)
size
- Requested sizepublic static void deallocateDBIDRange(DBIDRange range)
range
- Range to deallocatepublic static DBIDVar newVar(DBIDRef val)
val
- Initial value.public static DBIDVar newVar()
public static ArrayModifiableDBIDs newArray()
public static HashSetModifiableDBIDs newHashSet()
public static ArrayModifiableDBIDs newArray(int size)
size
- Size hintpublic static HashSetModifiableDBIDs newHashSet(int size)
size
- Size hintpublic static ArrayModifiableDBIDs newArray(DBIDs existing)
existing
- Existing DBIDspublic static HashSetModifiableDBIDs newHashSet(DBIDs existing)
existing
- Existing DBIDspublic static ModifiableDBIDs intersection(DBIDs first, DBIDs second)
first
- First setsecond
- Second setpublic static int intersectionSize(DBIDs first, DBIDs second)
first
- First setsecond
- Second setprivate static int internalIntersectionSize(DBIDs first, DBIDs second)
first
- First setsecond
- Second setpublic static void symmetricIntersection(DBIDs first, DBIDs second, HashSetModifiableDBIDs firstonly, HashSetModifiableDBIDs intersection, HashSetModifiableDBIDs secondonly)
first
- First setsecond
- Second setfirstonly
- OUTPUT: elements only in first. MUST BE EMPTYintersection
- OUTPUT: elements in intersection. MUST BE EMPTYsecondonly
- OUTPUT: elements only in second. MUST BE EMPTYpublic static ModifiableDBIDs union(DBIDs ids1, DBIDs ids2)
ids1
- the first collectionids2
- the second collectionpublic static ModifiableDBIDs difference(DBIDs ids1, DBIDs ids2)
ids1
- the first collectionids2
- the second collectionpublic static StaticDBIDs makeUnmodifiable(DBIDs existing)
existing
- Existing collectionpublic static ArrayDBIDs ensureArray(DBIDs ids)
ids
- IDspublic static SetDBIDs ensureSet(DBIDs ids)
ids
- IDspublic static ModifiableDBIDs ensureModifiable(DBIDs ids)
ids
- IDspublic static DBIDPair newPair(DBIDRef id1, DBIDRef id2)
id1
- first IDid2
- second IDpublic static DoubleDBIDPair newPair(double val, DBIDRef id)
val
- double valueid
- IDpublic static KNNHeap newHeap(int k)
k
- K valuepublic static KNNHeap newHeap(KNNList exist)
exist
- Existing resultpublic static void randomShuffle(ArrayModifiableDBIDs ids, RandomFactory rnd)
ids
- Original DBIDsrnd
- Random generatorpublic static void randomShuffle(ArrayModifiableDBIDs ids, Random random)
ids
- Original DBIDsrandom
- Random generatorpublic static void randomShuffle(ArrayModifiableDBIDs ids, Random random, int limit)
limit
elements will be randomized.ids
- Original DBIDsrandom
- Random generatorlimit
- Shuffling limit.public static ModifiableDBIDs randomSample(DBIDs source, int k, int seed)
source
- Original DBIDsk
- k Parameterseed
- Random generator seedpublic static ModifiableDBIDs randomSample(DBIDs source, int k, Long seed)
source
- Original DBIDsk
- k Parameterseed
- Random generator seedpublic static ModifiableDBIDs randomSample(DBIDs source, int k, RandomFactory rnd)
source
- Original DBIDsk
- k Parameterrnd
- Random generatorpublic static ModifiableDBIDs randomSample(DBIDs source, int k, Random random)
source
- Original DBIDsk
- k Parameterrandom
- Random generatorpublic static DBIDs randomSample(DBIDs ids, double rate, RandomFactory random)
ids
- Original idsrate
- Sampling raterandom
- Random generatorpublic static DBIDs randomSample(DBIDs ids, double rate, Random random)
ids
- Original idsrate
- Sampling raterandom
- Random generatorpublic static DBIDVar randomSample(DBIDs ids, Random random)
ids
- IDs to draw fromrandom
- Random valuepublic static DBIDVar randomSample(DBIDs ids, RandomFactory random)
ids
- IDs to draw fromrandom
- Random valuepublic static ArrayDBIDs[] randomSplit(DBIDs ids, int p, RandomFactory rnd)
p
partitions of almost-equal size.ids
- Original DBIDsp
- Desired number of partitions.rnd
- Random generatorpublic static ArrayDBIDs[] randomSplit(DBIDs oids, int p, Random random)
p
partitions of almost-equal size.oids
- Original DBIDsp
- Desired number of partitions.random
- Random generatorpublic static KNNList subList(KNNList list, int k)
list
- Existing listk
- kpublic static ModifiableDoubleDBIDList newDistanceDBIDList(int size)
size
- Estimated upper list sizepublic static ModifiableDoubleDBIDList newDistanceDBIDList()
public static DBIDRange assertRange(DBIDs ids)
DBIDRange
.ids
- ID range.AbortException
Copyright © 2015 ELKI Development Team, Lehr- und Forschungseinheit für Datenbanksysteme, Ludwig-Maximilians-Universität München. License information.