/** * Returns the indices of the array sorted in ascending order * @param valuesToSort values that should be sorted in ascending order, * via a call to Arrays.sort(), does not change values of "valuesToSort" * @return indices of the ascending-ordered valuesToSort, so that * index[0] is the smallest value, and index[index.length-1] is the biggest */ public static int[] sortArrayAscending( double[] valuesToSort ) { int M = valuesToSort.length; DoubleIntegerPair[] pairs = new DoubleIntegerPair[ M ]; for( int i = 0; i < M; i++ ) { pairs[ i ] = new DoubleIntegerPair( valuesToSort[i], i ); } Arrays.sort( pairs, new DefaultComparator<DoubleIntegerPair>() ); int[] indices = new int[ M ]; for( int i = 0; i < M; i++ ) { indices[i] = pairs[i].getIndex(); } return indices; }
/** * Returns the indices of the array sorted in ascending order * @param valuesToSort values that should be sorted in ascending order, * via a call to Arrays.sort(), does not change values of "valuesToSort" * @return indices of the ascending-ordered valuesToSort, so that * index[0] is the smallest value, and index[index.length-1] is the biggest */ public static int[] sortArrayAscending( double[] valuesToSort ) { int M = valuesToSort.length; DoubleIntegerPair[] pairs = new DoubleIntegerPair[ M ]; for( int i = 0; i < M; i++ ) { pairs[ i ] = new DoubleIntegerPair( valuesToSort[i], i ); } Arrays.sort( pairs, new DefaultComparator<DoubleIntegerPair>() ); int[] indices = new int[ M ]; for( int i = 0; i < M; i++ ) { indices[i] = pairs[i].getIndex(); } return indices; }
/** * Returns the indices of the array sorted in ascending order * @param valuesToSort values that should be sorted in ascending order, * via a call to Arrays.sort(), does not change values of "valuesToSort" * @return indices of the ascending-ordered valuesToSort, so that * index[0] is the smallest value, and index[index.length-1] is the biggest */ public static int[] sortArrayAscending( double[] valuesToSort ) { int M = valuesToSort.length; DoubleIntegerPair[] pairs = new DoubleIntegerPair[ M ]; for( int i = 0; i < M; i++ ) { pairs[ i ] = new DoubleIntegerPair( valuesToSort[i], i ); } Arrays.sort( pairs, new DefaultComparator<DoubleIntegerPair>() ); int[] indices = new int[ M ]; for( int i = 0; i < M; i++ ) { indices[i] = pairs[i].getIndex(); } return indices; }
@Override public boolean equals( final Object object) { return object instanceof DoubleIntegerPair && this.equals((DoubleIntegerPair) object); }
@Override public boolean equals( final Object object) { return object instanceof DoubleIntegerPair && this.equals((DoubleIntegerPair) object); }
/** * Determines if this object is equal to the given object. * * @param other The given object. * @return True if the two are equal; otherwise, false. */ public boolean equals( final DoubleIntegerPair other) { return other != null && this.getIndex() == other.getIndex() && this.getValue() == other.getValue(); }
/** * Determines if this object is equal to the given object. * * @param other The given object. * @return True if the two are equal; otherwise, false. */ public boolean equals( final DoubleIntegerPair other) { return other != null && this.getIndex() == other.getIndex() && this.getValue() == other.getValue(); }
/** * Determines if this object is equal to the given object. * * @param other The given object. * @return True if the two are equal; otherwise, false. */ public boolean equals( final DoubleIntegerPair other) { return other != null && this.getIndex() == other.getIndex() && this.getValue() == other.getValue(); }
@Override public boolean equals( final Object object) { return object instanceof DoubleIntegerPair && this.equals((DoubleIntegerPair) object); }