Class LongTuple

java.lang.Object
com.github.oeuvres.alix.util.LongTuple
All Implemented Interfaces:
Comparable<LongTuple>

public class LongTuple extends Object implements Comparable<LongTuple>
A fixed list of longs, useful in arrays to be sorted.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected final long[]
    Internal data
    protected int
    Cache an hash code
    protected boolean
    Should be rehashed
    protected Murmur3A
    Hash code producer
    protected final int
    Size of tuple
  • Constructor Summary

    Constructors
    Constructor
    Description
    LongTuple(int size)
    Constructor setting the size.
    LongTuple(long a, long b)
    Build a pair.
    LongTuple(long a, long b, long c)
    Build a 3-tuple.
  • Method Summary

    Modifier and Type
    Method
    Description
    int
     
    boolean
     
    long
    get(int index)
    Like List.get(int), returns the element at the specified position in this list.
    int
     
    int
    Like List.size(), returns the number of elements in this list.
    long[]
    Like List.toArray(), returns an array containing all of the elements in this list in proper sequence (from first to last element).
    long[]
    toArray(long[] dest)
    Fill the provided array with sorted values, or create new if null provided.
     

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Field Details

    • data

      protected final long[] data
      Internal data
    • size

      protected final int size
      Size of tuple
    • hashCache

      protected int hashCache
      Cache an hash code
    • hashOK

      protected boolean hashOK
      Should be rehashed
    • murmur

      protected Murmur3A murmur
      Hash code producer
  • Constructor Details

    • LongTuple

      public LongTuple(int size)
      Constructor setting the size.
      Parameters:
      size - number of long in this tuple.
    • LongTuple

      public LongTuple(long a, long b)
      Build a pair.
      Parameters:
      a - first element of the pair.
      b - second element of the pair.
    • LongTuple

      public LongTuple(long a, long b, long c)
      Build a 3-tuple.
      Parameters:
      a - first element of the triplet.
      b - second element of the triplet.
      c - third element of the triplet.
  • Method Details

    • compareTo

      public int compareTo(LongTuple tuple)
      Specified by:
      compareTo in interface Comparable<LongTuple>
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • get

      public long get(int index)
      Like List.get(int), returns the element at the specified position in this list.
      Parameters:
      index - position of the element to return.
      Returns:
      The element at the specified position in this list.
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toArray

      public long[] toArray()
      Like List.toArray(), returns an array containing all of the elements in this list in proper sequence (from first to last element).
      Returns:
      An array containing all of the elements in this list in proper sequence.
    • toArray

      public long[] toArray(long[] dest)
      Fill the provided array with sorted values, or create new if null provided. If the list fits in the specified array, it is returned therein, without modification of further positions. If the array provided is smaller than list content, it is filled up to its length.
      Parameters:
      dest - array to fill in, up to dest.length.
      Returns:
      same array.
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • size

      public int size()
      Like List.size(), returns the number of elements in this list.
      Returns:
      The number of elements in this list.