Interface ArrayExchanger32

All Superinterfaces:
ArrayExchanger
All Known Implementing Classes:
JArrays.ByteAndIndexArrayExchanger, JArrays.ByteArrayExchanger, JArrays.CharAndIndexArrayExchanger, JArrays.CharArrayExchanger, JArrays.DoubleAndIndexArrayExchanger, JArrays.DoubleArrayExchanger, JArrays.FloatAndIndexArrayExchanger, JArrays.FloatArrayExchanger, JArrays.IntAndIndexArrayExchanger, JArrays.IntArrayExchanger, JArrays.LongAndIndexArrayExchanger, JArrays.LongArrayExchanger, JArrays.ShortAndIndexArrayExchanger, JArrays.ShortArrayExchanger
Functional Interface:
This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.

@FunctionalInterface public interface ArrayExchanger32 extends ArrayExchanger

Version of ArrayExchanger for a case of 32-bit indexes (int instead of long).

Author:
Daniel Alievsky
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    swap(int first, int second)
    Should exchange the elements at position first and second in the data array.
    default void
    swap(long first, long second)
    This method, implemented in this interface, just calls another swap method with int indexes:
  • Method Details

    • swap

      default void swap(long first, long second)
      This method, implemented in this interface, just calls another swap method with int indexes:
           swap((int) first, (int) second);
       
      Note: for maximal performance, it does not check that the passed intexes are really 32-bit. While using with arrays, containing 231 elements or more, this comparator will work incorrecly.
      Specified by:
      swap in interface ArrayExchanger
      Parameters:
      first - index of the first exchanged element.
      second - index of the second exchanged element.
    • swap

      void swap(int first, int second)
      Should exchange the elements at position first and second in the data array.
      Parameters:
      first - index of the first exchanged element.
      second - index of the second exchanged element.