Class JArrays.ShortArrayComparator

java.lang.Object
net.algart.arrays.JArrays.ShortArrayComparator
All Implemented Interfaces:
ArrayComparator, ArrayComparator32
Enclosing class:
JArrays

public static class JArrays.ShortArrayComparator extends Object implements ArrayComparator32
Simple implementation of ArrayComparator, comparing elements of short[] array.

Note that the elements of short[] array are supposed to be unsigned: we always compare array[i] & 0xFFFF and array[j] & 0xFFFF instead of simple array[i] and array[j].

  • Constructor Summary

    Constructors
    Constructor
    Description
    ShortArrayComparator(short[] array)
    Creates new comparator, comparing elements of the passed array.
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    less(int first, int second)
    Returns true if, and only if, the element array[(int)first] is less than the element array[(int)second], where array is the argument of the constructor.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface net.algart.arrays.ArrayComparator32

    less
  • Constructor Details

    • ShortArrayComparator

      public ShortArrayComparator(short[] array)
      Creates new comparator, comparing elements of the passed array.
      Parameters:
      array - some Java array.
      Throws:
      NullPointerException - if the argument is null.
  • Method Details

    • less

      public boolean less(int first, int second)
      Returns true if, and only if, the element array[(int)first] is less than the element array[(int)second], where array is the argument of the constructor.
      Specified by:
      less in interface ArrayComparator32
      Parameters:
      first - index of the first compared element.
      second - index of the second compared element.
      Returns:
      whether the element #first is less than the element #second.