Package org.snpeff.collections
Class HashLongLongArray
java.lang.Object
org.snpeff.collections.HashLongLongArray
A Hash<long, long[]> using primitive types instead or warped object
The idea is to be able to add many long values for each key
This could be implemented by simply doing HashMap<Long, Set > (but it
would consume much more memory)
Note: We call each 'long[]' a bucket
WARNING: This collection does NOT allow elements to be deleted! But you can replace values.
- Author:
- pcingola
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionboolean
contains
(long key, long value) Return true if value is in the hashlong[]
getBucket
(long key) Return all values for a given key WARNING: Not all elements in a bucket are used.int
getBucketLength
(long key) Return used length of a bucketint
Get bucket length for latest bucket search WARNING: Obviously this is not a thread safe operationlong[]
keys()
Return an array with all the keys to this hashvoid
put
(long key, long value) Insert a <key, value> pair How does it work? - bucket_number = hash.get( key ) - bu = bucket[ bucket_number ] - append 'value' to 'bu'boolean
replace
(long key, long value, long newValue) Replace a value with newValuetoString()
-
Field Details
-
EMPTY_VALUE
public static final long EMPTY_VALUE- See Also:
-
-
Constructor Details
-
HashLongLongArray
public HashLongLongArray()
-
-
Method Details
-
contains
public boolean contains(long key, long value) Return true if value is in the hash- Parameters:
key
-value
-
-
getBucket
public long[] getBucket(long key) Return all values for a given key WARNING: Not all elements in a bucket are used. Use getBucketLength(key) to know how many elements are used- Parameters:
key
-- Returns:
- All associated values, or null if key is not found
-
getBucketLength
public int getBucketLength(long key) Return used length of a bucket- Parameters:
key
-- Returns:
-
getLatestBucketLength
public int getLatestBucketLength()Get bucket length for latest bucket search WARNING: Obviously this is not a thread safe operation- Returns:
-
keys
public long[] keys()Return an array with all the keys to this hash- Returns:
-
put
public void put(long key, long value) Insert a <key, value> pair How does it work? - bucket_number = hash.get( key ) - bu = bucket[ bucket_number ] - append 'value' to 'bu'- Parameters:
key
-value
-
-
replace
public boolean replace(long key, long value, long newValue) Replace a value with newValue- Parameters:
key
-value
-
-
toString
-