Package org.snpsift.annotate.mem.arrays
Class PosIndex
java.lang.Object
org.snpsift.annotate.mem.arrays.PosIndex
- All Implemented Interfaces:
Serializable
An index by possition
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionint
capacity()
void
check()
Check that all positions are in non-decreasing order.boolean
contains
(int pos) int
get
(int i) Get position at index 'i'int
indexOf
(int pos) Find the index of a position using binary searchint
indexOfSlow
(int pos) Find the index of a position using a (slow) linear search Used for testingvoid
set
(int i, int pos) Set position to entry number 'i'int
size()
Number of entries in uselong
Memory size of this object (approximate size in bytes)
-
Constructor Details
-
PosIndex
public PosIndex(int numEntries)
-
-
Method Details
-
capacity
public int capacity() -
check
public void check()Check that all positions are in non-decreasing order. This is necesary because we use binary search to find positions -
contains
public boolean contains(int pos) -
get
public int get(int i) Get position at index 'i' -
indexOf
public int indexOf(int pos) Find the index of a position using binary search- Parameters:
pos
- : A zero-based position- Returns:
- index of the position or negative number if not found
-
indexOfSlow
public int indexOfSlow(int pos) Find the index of a position using a (slow) linear search Used for testing- Parameters:
pos
- : A zero-based position- Returns:
- index of the position or negative number if not found
-
set
public void set(int i, int pos) Set position to entry number 'i' -
size
public int size()Number of entries in use -
sizeBytes
public long sizeBytes()Memory size of this object (approximate size in bytes)
-