Package org.snpeff.collections
Class HashLongLongArray
- java.lang.Object
-
- org.snpeff.collections.HashLongLongArray
-
public class HashLongLongArray extends java.lang.Object
A Hashusing 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 > (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 Modifier and Type Field Description static long
EMPTY_VALUE
-
Constructor Summary
Constructors Constructor Description HashLongLongArray()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
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
getLatestBucketLength()
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 apair 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 newValuejava.lang.String
toString()
-
-
-
Field Detail
-
EMPTY_VALUE
public static final long EMPTY_VALUE
- See Also:
- Constant Field Values
-
-
Method Detail
-
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 apair 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
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-