Class JArrays.DoubleAndIndexArrayExchanger

java.lang.Object
net.algart.arrays.JArrays.DoubleAndIndexArrayExchanger
All Implemented Interfaces:
ArrayExchanger, ArrayExchanger32
Enclosing class:
JArrays

public static class JArrays.DoubleAndIndexArrayExchanger extends Object implements ArrayExchanger32
Implementation of ArrayExchanger, that simultaneously exchanges two pairs elements at the same positions in two arrays: some double[] array and some int[] array. It is convenient, when the 1st array contains data and the 2nd array contains some "indexes", and we want to exchange indexes simultaneously with sorting the data array.
  • Constructor Summary

    Constructors
    Constructor
    Description
    DoubleAndIndexArrayExchanger(double[] array, int[] indexes)
    Creates new exchanger, exchanging elements of both passed arrays.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    swap(int first, int second)
    Exchanges two pair: 1) elements array[(int)first] and array[(int)second], 2) elements indexes[(int)first] and indexes[(int)second], where array and indexesare the arguments 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.ArrayExchanger32

    swap
  • Constructor Details

    • DoubleAndIndexArrayExchanger

      public DoubleAndIndexArrayExchanger(double[] array, int[] indexes)
      Creates new exchanger, exchanging elements of both passed arrays.
      Parameters:
      array - some Java array.
      indexes - another Java array.
      Throws:
      NullPointerException - if one of the arguments is null.
  • Method Details

    • swap

      public void swap(int first, int second)
      Exchanges two pair: 1) elements array[(int)first] and array[(int)second], 2) elements indexes[(int)first] and indexes[(int)second], where array and indexesare the arguments of the constructor.
      Specified by:
      swap in interface ArrayExchanger32
      Parameters:
      first - index of the first exchanged element.
      second - index of the second exchanged element.