Class StableVectorComparator<V extends ValueVector>

Type Parameters:
V - type of the vector.

public class StableVectorComparator<V extends ValueVector> extends VectorValueComparator<V>
Stable sorter. It compares values like ordinary comparators. However, when values are equal, it breaks ties by the value indices. Therefore, sort algorithms using this comparator always produce stable sort results.
  • Constructor Details

    • StableVectorComparator

      public StableVectorComparator(VectorValueComparator<V> innerComparator)
      Constructs a stable comparator from a given comparator.
      innerComparator - the comparator to convert to stable comparator..
  • Method Details

    • attachVector

      public void attachVector(V vector)
      Description copied from class: VectorValueComparator
      Attach both vectors to compare to the same input vector.
      attachVector in class VectorValueComparator<V extends ValueVector>
      vector - the vector to attach.
    • attachVectors

      public void attachVectors(V vector1, V vector2)
      Description copied from class: VectorValueComparator
      Attach vectors to compare.
      attachVectors in class VectorValueComparator<V extends ValueVector>
      vector1 - the first vector to compare.
      vector2 - the second vector to compare.
    • compareNotNull

      public int compareNotNull(int index1, int index2)
      Description copied from class: VectorValueComparator
      Compare two values, given their indices. This is a fast path for comparing non-null values, so the caller must make sure that values at both indices are not null.
      Specified by:
      compareNotNull in class VectorValueComparator<V extends ValueVector>
      index1 - index of the first value to compare.
      index2 - index of the second value to compare.
      an integer greater than 0, if the first value is greater; an integer smaller than 0, if the first value is smaller; or 0, if both values are equal.
    • createNew

      public VectorValueComparator<V> createNew()
      Description copied from class: VectorValueComparator
      Creates a comparator of the same type.
      Specified by:
      createNew in class VectorValueComparator<V extends ValueVector>
      the newly created comparator.