@Override public long lastIndexOf(final long k) { for (long i = size; i-- != 0;) if (((k) == (LongBigArrays.get(a, i)))) return i; return -1; } @Override
@Override public long indexOf(final long k) { for (long i = 0; i < size; i++) if (((k) == (LongBigArrays.get(a, i)))) return i; return -1; } @Override
/** * Reads a coded length. * * @param a * the data big array. * @param pos * the starting position. * @return the length coded at {@code pos}. */ private static int readInt(final long a[][], long pos) { return (int) LongBigArrays.get(a, pos); } /**
private static long med3(final long x[][], final long a, final long b, final long c) { int ab = (Long.compare((get(x, a)), (get(x, b)))); int ac = (Long.compare((get(x, a)), (get(x, c)))); int bc = (Long.compare((get(x, b)), (get(x, c)))); return (ab < 0 ? (bc < 0 ? b : ac < 0 ? c : a) : (bc > 0 ? b : ac > 0 ? c : a)); }
@Override public long getLong(final long index) { if (index >= size) throw new IndexOutOfBoundsException( "Index (" + index + ") is greater than or equal to list size (" + size + ")"); return LongBigArrays.get(a, index); } @Override
private void writeObject(java.io.ObjectOutputStream s) throws java.io.IOException { s.defaultWriteObject(); for (int i = 0; i < size; i++) s.writeLong(LongBigArrays.get(a, i)); }
private static long med3(final long x[][], final long a, final long b, final long c, LongComparator comp) { int ab = comp.compare(get(x, a), get(x, b)); int ac = comp.compare(get(x, a), get(x, c)); int bc = comp.compare(get(x, b), get(x, c)); return (ab < 0 ? (bc < 0 ? b : ac < 0 ? c : a) : (bc > 0 ? b : ac > 0 ? c : a)); } private static void selectionSort(final long[][] a, final long from, final long to, final LongComparator comp) {
private static void selectionSort(final long[][] a, final long[][] 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 (((LongBigArrays.get(a, j)) < (LongBigArrays.get(a, m))) || ((LongBigArrays.get(a, j)) == (LongBigArrays.get(a, m))) && ((LongBigArrays.get(b, j)) < (LongBigArrays.get(b, m)))) m = j; if (m != i) { long t = LongBigArrays.get(a, i); LongBigArrays.set(a, i, LongBigArrays.get(a, m)); LongBigArrays.set(a, m, t); t = LongBigArrays.get(b, i); LongBigArrays.set(b, i, LongBigArrays.get(b, m)); LongBigArrays.set(b, m, t); } } } /**
@Override public long set(final long index, final long k) { if (index >= size) throw new IndexOutOfBoundsException( "Index (" + index + ") is greater than or equal to list size (" + size + ")"); long old = LongBigArrays.get(a, index); LongBigArrays.set(a, index, k); return old; } @Override
@Override public long nextLong() { if (!hasNext()) throw new NoSuchElementException(); return LongBigArrays.get(a, last = pos++); } @Override
@Override public long previousLong() { if (!hasPrevious()) throw new NoSuchElementException(); return LongBigArrays.get(a, last = --pos); } @Override
private static void selectionSort(final long[][] a, final long from, final long to, final LongComparator comp) { for (long i = from; i < to - 1; i++) { long m = i; for (long j = i + 1; j < to; j++) if (comp.compare(LongBigArrays.get(a, j), LongBigArrays.get(a, m)) < 0) m = j; if (m != i) swap(a, i, m); } } /**
public static String toString(final long[][] 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(", "); } } /**
/** * Compares this type-specific big-array list to another one. * * <p> * This method exists only for sake of efficiency. The implementation inherited * from the abstract implementation would already work. * * @param l * a type-specific big-array list. * @return true if the argument contains the same elements of this type-specific * big-array list. */ public boolean equals(final LongBigArrayBigList l) { if (l == this) return true; long s = size64(); if (s != l.size64()) return false; final long[][] a1 = a; final long[][] a2 = l.a; while (s-- != 0) if (LongBigArrays.get(a1, s) != LongBigArrays.get(a2, s)) return false; return true; } /**
@Override public long removeLong(final long index) { if (index >= size) throw new IndexOutOfBoundsException( "Index (" + index + ") is greater than or equal to list size (" + size + ")"); final long old = LongBigArrays.get(a, index); size--; if (index != size) LongBigArrays.copy(a, index + 1, a, index, size - index); assert size <= LongBigArrays.length(a); return old; } @Override
/** * Compares this big list to another big list. * * <p> * This method exists only for sake of efficiency. The implementation inherited * from the abstract implementation would already work. * * @param l * a big list. * @return a negative integer, zero, or a positive integer as this big list is * lexicographically less than, equal to, or greater than the argument. */ public int compareTo(final LongBigArrayBigList l) { final long s1 = size64(), s2 = l.size64(); final long a1[][] = a, a2[][] = l.a; long e1, e2; int r, i; for (i = 0; i < s1 && i < s2; i++) { e1 = LongBigArrays.get(a1, i); e2 = LongBigArrays.get(a2, i); if ((r = (Long.compare((e1), (e2)))) != 0) return r; } return i < s2 ? -1 : (i < s1 ? 1 : 0); } private void writeObject(java.io.ObjectOutputStream s) throws java.io.IOException {
/** * 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 long[][] key = this.key; for (;;) { pos = ((last = pos) + 1) & mask; for (;;) { if (((LongBigArrays.get(key, pos)) == (0))) { LongBigArrays.set(key, last, (0)); return; } slot = it.unimi.dsi.fastutil.HashCommon.mix((LongBigArrays.get(key, pos))) & mask; if (last <= pos ? last >= slot || slot > pos : last >= slot && slot > pos) break; pos = (pos + 1) & mask; } LongBigArrays.set(key, last, LongBigArrays.get(key, pos)); } } private boolean removeEntry(final int base, final int displ) {
/** * 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 long[][] shuffle(final long[][] a, final Random random) { for (long i = length(a); i-- != 0;) { final long p = (random.nextLong() & 0x7FFFFFFFFFFFFFFFL) % (i + 1); final long t = get(a, i); set(a, i, get(a, p)); set(a, p, t); } return a; } }
/** * {@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 addElements(long index, final long a[][], long offset, long length) { ensureIndex(index); LongBigArrays.ensureOffsetLength(a, offset, length); while (length-- != 0) add(index++, LongBigArrays.get(a, offset++)); } /**