private void readObject(java.io.ObjectInputStream s) throws java.io.IOException, ClassNotFoundException { s.defaultReadObject(); a = IntBigArrays.newBigArray(size); for (int i = 0; i < size; i++) IntBigArrays.set(a, i, s.readInt()); } }
/** * 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 int[][] shuffle(final int[][] a, final Random random) { for (long i = length(a); i-- != 0;) { final long p = (random.nextLong() & 0x7FFFFFFFFFFFFFFFL) % (i + 1); final int t = get(a, i); set(a, i, get(a, p)); set(a, p, t); } return a; } }
@Override public void size(final long size) { if (size > IntBigArrays.length(a)) a = IntBigArrays.forceCapacity(a, size, this.size); if (size > this.size) IntBigArrays.fill(a, this.size, size, (0)); this.size = size; } @Override
/** * Ensures that this big-array big list can contain the given number of entries * without resizing. * * @param capacity * the new minimum capacity for this big-array big list. */ public void ensureCapacity(final long capacity) { if (capacity <= a.length || a == IntBigArrays.DEFAULT_EMPTY_BIG_ARRAY) return; a = IntBigArrays.forceCapacity(a, capacity, size); assert size <= IntBigArrays.length(a); } /**
@Override public long indexOf(final int k) { for (long i = 0; i < size; i++) if (((k) == (IntBigArrays.get(a, i)))) return i; return -1; } @Override
/** * Creates a new big-array big list with given capacity. * * @param capacity * the initial capacity of the array list (may be 0). */ public IntBigArrayBigList(final long capacity) { if (capacity < 0) throw new IllegalArgumentException("Initial capacity (" + capacity + ") is negative"); if (capacity == 0) a = IntBigArrays.EMPTY_BIG_ARRAY; else a = IntBigArrays.newBigArray(capacity); } /**
public static void main(final String arg[]) { int[][] a = IntBigArrays.newBigArray(1L << Integer.parseInt(arg[0])); long x, y, z, start; for (long i = IntBigArrays.length(a); i-- != 0;) x ^= i ^ IntBigArrays.get(a, i); if (x == 0) System.err.println(); long j = IntBigArrays.length(a); for (int i = a.length; i-- != 0;) { final int[] t = a[i];
if (IntBigArrays.length(a) != IntBigArrays.length(b)) throw new IllegalArgumentException("Array size mismatch."); final int maxLevel = DIGITS_PER_ELEMENT * layers - 1; final int signMask = level % DIGITS_PER_ELEMENT == 0 ? 1 << DIGIT_BITS - 1 : 0; if (length < MEDIUM) { selectionSort(a, b, first, first + length); continue; (byte) ((((IntBigArrays.get(k, first + i)) >>> shift) & DIGIT_MASK) ^ signMask)); for (long i = length; i-- != 0;) count[ByteBigArrays.get(digit, i) & 0xFF]++; int t = IntBigArrays.get(a, i + first); int u = IntBigArrays.get(b, i + first); c = ByteBigArrays.get(digit, i) & 0xFF; while ((d = --pos[c]) > i) { int z = t; final int zz = c; t = IntBigArrays.get(a, d + first); IntBigArrays.set(a, d + first, z); z = u; u = IntBigArrays.get(b, d + first); IntBigArrays.set(b, d + first, z); c = ByteBigArrays.get(digit, d) & 0xFF; ByteBigArrays.set(digit, d, (byte) zz); IntBigArrays.set(a, i + first, t); IntBigArrays.set(b, i + first, u);
final int[][] lcpLength = IntBigArrays.newBigArray(lcps.size64()); long p = 0; for(final LongArrayBitVector bv : lcps) IntBigArrays.set(lcpLength, p++, (int)bv.length()); final long index = mph.getLongByTriple(quadruple); offsets.set(index, quadruple[3] & bucketSizeMask); lcpLengthsTemp.set(index, IntBigArrays.get(lcpLength, (int)(quadruple[3] >> log2BucketSize)));
selectionSort(x, from, to); return; if (len > MEDIUM) { // Big arrays, pseudomedian of 9 long s = len / 8; l = med3(x, l, l + s, l + 2 * s); m = med3(x, m - s, m, m + s); n = med3(x, n - 2 * s, n - s, n); m = med3(x, l, m, n); // Mid-size, med of 3 final int v = get(x, m); while (b <= c && (comparison = (Integer.compare((get(x, b)), (v)))) <= 0) { if (comparison == 0) swap(x, a++, b); b++; while (c >= b && (comparison = (Integer.compare((get(x, c)), (v)))) >= 0) { if (comparison == 0) swap(x, c, d--); c--; swap(x, b++, c--); vecSwap(x, from, b - s, s); s = Math.min(d - c, n - d - 1); vecSwap(x, b, n - s, s);
@Override public int removeInt(final long index) { if (index >= size) throw new IndexOutOfBoundsException( "Index (" + index + ") is greater than or equal to list size (" + size + ")"); final int old = IntBigArrays.get(a, index); size--; if (index != size) IntBigArrays.copy(a, index + 1, a, index, size - index); assert size <= IntBigArrays.length(a); return old; } @Override
@Override public void clear() { size = 0; assert size <= IntBigArrays.length(a); } @Override
if ( indexingIsVirtual && virtualDocumentGap == 0 ) throw new IllegalArgumentException( "Illegal virtual document gap: " + virtualDocumentGap ); if ( indexingIsVirtual ) currSize = IntBigArrays.newBigArray( numVirtualDocs ); maxDocInBatch = ( currSize != null ? IntBigArrays.length( currSize ) : 0 ) -1; openSizeBitStream();
final int signMask = level % DIGITS_PER_ELEMENT == 0 ? 1 << DIGIT_BITS - 1 : 0; if (length < MEDIUM) { selectionSort(a, first, first + length); continue; (byte) ((((IntBigArrays.get(a, first + i)) >>> shift) & DIGIT_MASK) ^ signMask)); for (long i = length; i-- != 0;) count[ByteBigArrays.get(digit, i) & 0xFF]++; int t = IntBigArrays.get(a, i + first); c = ByteBigArrays.get(digit, i) & 0xFF; while ((d = --pos[c]) > i) { final int z = t; final int zz = c; t = IntBigArrays.get(a, d + first); c = ByteBigArrays.get(digit, d) & 0xFF; IntBigArrays.set(a, d + first, z); ByteBigArrays.set(digit, d, (byte) zz); IntBigArrays.set(a, i + first, t);
public static String toString(final int[][] a) { if (a == null) return "null"; final long last = length(a) - 1; if (last == -1) return "[]"; final StringBuilder b = new StringBuilder(); b.append('['); for (long i = 0;; i++) { b.append(String.valueOf(get(a, i))); if (i == last) return b.append(']').toString(); b.append(", "); } } /**
/** * Returns a copy of a portion of a big array. * * @param array * a big array. * @param offset * the first element to copy. * @param length * the number of elements to copy. * @return a new big array containing {@code length} elements of {@code array} * starting at {@code offset}. */ public static int[][] copy(final int[][] array, final long offset, final long length) { ensureOffsetLength(array, offset, length); final int[][] a = newBigArray(length); copy(array, offset, a, 0, length); return a; } /**