Class PosIndex

java.lang.Object
org.snpsift.annotate.mem.arrays.PosIndex
All Implemented Interfaces:
Serializable

public class PosIndex extends Object implements Serializable
The PosIndex class is designed to manage and index chromosome positions efficiently converting chromosome positions to zero-based indices. It stores an array of integer positions and provides methods to manipulate and query these positions. Intended Use: - This class is used to store chromosome positions and allows for efficient searching and validation. - It ensures that positions are stored in a non-decreasing order to facilitate binary search operations. How it Works: - The positions are stored in an integer array, and the size of the array is determined by the number of entries specified during instantiation. - The class provides methods to set positions, check if positions are sorted, and search for positions using both binary and linear search algorithms. - The `check` method ensures that all positions are in non-decreasing order. - The `indexOf` method uses binary search to find the index of a given position (while the `indexOfSlow` method uses a linear search, it's only used for testing and debugging). - The `size` method returns the number of entries in use, and the `sizeBytes` method returns the approximate memory size of the object in bytes.
See Also:
  • Constructor Summary

    Constructors
    Constructor
    Description
    PosIndex(int numEntries)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    int
     
    void
    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 search
    int
    indexOfSlow(int pos)
    Find the index of a position using a (slow) linear search Used for testing
    void
    set(int i, int pos)
    Set position to entry number 'i'
    int
    Number of entries in use
    long
    Memory size of this object (approximate size in bytes)

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • 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)