Package net.algart.arrays
Class JArrays.ByteAndIndexArrayExchanger
java.lang.Object
net.algart.arrays.JArrays.ByteAndIndexArrayExchanger
- All Implemented Interfaces:
ArrayExchanger
,ArrayExchanger32
- Enclosing class:
JArrays
Implementation of
ArrayExchanger
, that simultaneously exchanges two pairs elements at the same
positions in two arrays: some byte[] 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
ConstructorDescriptionByteAndIndexArrayExchanger
(byte[] array, int[] indexes) Creates new exchanger, exchanging elements of both passed arrays. -
Method Summary
Modifier and TypeMethodDescriptionvoid
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
-
ByteAndIndexArrayExchanger
public ByteAndIndexArrayExchanger(byte[] 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 interfaceArrayExchanger32
- Parameters:
first
- index of the first exchanged element.second
- index of the second exchanged element.
-