@Override public double set(final long index, final double k) { if (index >= size) throw new IndexOutOfBoundsException( "Index (" + index + ") is greater than or equal to list size (" + size + ")"); double old = DoubleBigArrays.get(a, index); DoubleBigArrays.set(a, index, k); return old; } @Override
/** * Shuffles the specified big array fragment using the specified pseudorandom * number generator. * * @param a * the big array to be shuffled. * @param from * the index of the first element (inclusive) to be shuffled. * @param to * the index of the last element (exclusive) to be shuffled. * @param random * a pseudorandom number generator. * @return {@code a}. */ public static double[][] shuffle(final double[][] a, final long from, final long to, final Random random) { for (long i = to - from; i-- != 0;) { final long p = (random.nextLong() & 0x7FFFFFFFFFFFFFFFL) % (i + 1); final double t = get(a, from + i); set(a, from + i, get(a, from + p)); set(a, from + p, t); } return a; } /**
private void readObject(java.io.ObjectInputStream s) throws java.io.IOException, ClassNotFoundException { s.defaultReadObject(); a = DoubleBigArrays.newBigArray(size); for (int i = 0; i < size; i++) DoubleBigArrays.set(a, i, s.readDouble()); } }
@Override public boolean add(final double k) { grow(size + 1); DoubleBigArrays.set(a, size++, k); assert size <= DoubleBigArrays.length(a); return true; } @Override
/** * Shuffles the specified big array using the specified pseudorandom number * generator. * * @param a * the big array to be shuffled. * @param random * a pseudorandom number generator. * @return {@code a}. */ public static double[][] shuffle(final double[][] a, final Random random) { for (long i = length(a); i-- != 0;) { final long p = (random.nextLong() & 0x7FFFFFFFFFFFFFFFL) % (i + 1); final double t = get(a, i); set(a, i, get(a, p)); set(a, p, t); } return a; } }
/** * Shifts left entries with the specified hash code, starting at the specified * position, and empties the resulting free entry. * * @param pos * a starting position. */ protected final void shiftKeys(long pos) { // Shift entries with the same hash. long last, slot; final double[][] key = this.key; for (;;) { pos = ((last = pos) + 1) & mask; for (;;) { if ((Double.doubleToLongBits(DoubleBigArrays.get(key, pos)) == 0)) { DoubleBigArrays.set(key, last, (0)); return; } slot = it.unimi.dsi.fastutil.HashCommon.mix(Double.doubleToRawLongBits(DoubleBigArrays.get(key, pos))) & mask; if (last <= pos ? last >= slot || slot > pos : last >= slot && slot > pos) break; pos = (pos + 1) & mask; } DoubleBigArrays.set(key, last, DoubleBigArrays.get(key, pos)); } } private boolean removeEntry(final int base, final int displ) {
private static void selectionSort(final double[][] a, final double[][] b, final long from, final long to) { for (long i = from; i < to - 1; i++) { long m = i; for (long j = i + 1; j < to; j++) if ((Double.compare((DoubleBigArrays.get(a, j)), (DoubleBigArrays.get(a, m))) < 0) || (Double.compare((DoubleBigArrays.get(a, j)), (DoubleBigArrays.get(a, m))) == 0) && (Double.compare((DoubleBigArrays.get(b, j)), (DoubleBigArrays.get(b, m))) < 0)) m = j; if (m != i) { double t = DoubleBigArrays.get(a, i); DoubleBigArrays.set(a, i, DoubleBigArrays.get(a, m)); DoubleBigArrays.set(a, m, t); t = DoubleBigArrays.get(b, i); DoubleBigArrays.set(b, i, DoubleBigArrays.get(b, m)); DoubleBigArrays.set(b, m, t); } } } /**
if ( type.equals( "int" ) ) for( int i = 0; i < n; i++ ) DoubleBigArrays.set( score, i, dis.readInt() ); else if ( type.equals( "long" ) ) for( int i = 0; i < n; i++ ) DoubleBigArrays.set( score, i, dis.readLong() ); else if ( type.equals( "float" ) ) for( int i = 0; i < n; i++ ) DoubleBigArrays.set( score, i, dis.readFloat() ); else if ( type.equals( "double" ) ) for( int i = 0; i < n; i++ ) DoubleBigArrays.set( score, i, dis.readDouble() ); else throw new IllegalArgumentException( "Unknown type \"" + type + "\"" );
@Override public void add(final long index, final double k) { ensureIndex(index); grow(size + 1); if (index != size) DoubleBigArrays.copy(a, index, a, index + 1, size - index); DoubleBigArrays.set(a, index, k); size++; assert size <= DoubleBigArrays.length(a); } @Override
/** * {@inheritDoc} * * <p> * This is a trivial iterator-based implementation. It is expected that * implementations will override this method with a more optimized version. */ @Override public void getElements(final long from, final double a[][], long offset, long length) { DoubleBigListIterator i = listIterator(from); DoubleBigArrays.ensureOffsetLength(a, offset, length); if (from + length > size64()) throw new IndexOutOfBoundsException( "End index (" + (from + length) + ") is greater than list size (" + size64() + ")"); while (length-- != 0) DoubleBigArrays.set(a, offset++, i.nextDouble()); } /**
final int zz = c; t = DoubleBigArrays.get(a, d + first); DoubleBigArrays.set(a, d + first, z); z = u; u = DoubleBigArrays.get(b, d + first); DoubleBigArrays.set(b, d + first, z); c = ByteBigArrays.get(digit, d) & 0xFF; ByteBigArrays.set(digit, d, (byte) zz); DoubleBigArrays.set(a, i + first, t); DoubleBigArrays.set(b, i + first, u);