Class IndexedList.IndexGenerator

java.lang.Object
org.jlab.utils.groups.IndexedList.IndexGenerator
Enclosing class:
IndexedList<T>

public static class IndexedList.IndexGenerator extends Object
Utility class for generating and decoding a long key from a multi-dimensional index. Default is up to 4 indices with 16 bits, but any byte shifts can be set up to a max of 64
Author:
gavalian
  • Constructor Summary Link icon

    Constructors
    Constructor
    Description
    Constructs an IndexGenerator with generic index size.
    IndexGenerator(int[] byteShifts)
    Constructs an IndexGenerator from a given byte shifts array.
  • Method Summary Link icon

    Modifier and Type
    Method
    Description
    int[]
    Get the byte shifts
    int
    getIndex(long hashcode, int order)
    Retrieves a specific index from the encoded long key.
    int[]
    Get the max value allowed for each index
    getString(long hashcode)
    Returns a formatted string representing all indices in the hash key.
    long
    hashCode(int... indices)
    Generates a long key from the given array of indices.

    Methods inherited from class java.lang.Object Link icon

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details Link icon

    • IndexGenerator Link icon

      public IndexGenerator()
      Constructs an IndexGenerator with generic index size.
    • IndexGenerator Link icon

      public IndexGenerator(int[] byteShifts)
      Constructs an IndexGenerator from a given byte shifts array.
      Parameters:
      byteShifts - the array of byte shifts to consider
  • Method Details Link icon

    • getByteShifts Link icon

      public int[] getByteShifts()
      Get the byte shifts
      Returns:
      the array of byte shifts
    • getMaxValues Link icon

      public int[] getMaxValues()
      Get the max value allowed for each index
      Returns:
      the array of max values
    • hashCode Link icon

      public long hashCode(int... indices)
      Generates a long key from the given array of indices.
      Parameters:
      indices - the index array
      Returns:
      a long key representing the hashed index
      Throws:
      IllegalArgumentException - if the number of indices exceeds supported length
    • getIndex Link icon

      public int getIndex(long hashcode, int order)
      Retrieves a specific index from the encoded long key.
      Parameters:
      hashcode - the encoded long key
      order - the position of the index to retrieve
      Returns:
      the decoded index
    • getString Link icon

      public String getString(long hashcode)
      Returns a formatted string representing all indices in the hash key.
      Parameters:
      hashcode - the encoded long key
      length - the number of indices to extract
      Returns:
      a string representation of the indices