Java Code Examples for it.unimi.dsi.fastutil.bytes.ByteArrays#EMPTY_ARRAY
The following examples show how to use
it.unimi.dsi.fastutil.bytes.ByteArrays#EMPTY_ARRAY .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ByteArrayCharSequence.java From BUbiNG with Apache License 2.0 | 4 votes |
/** Creates a new empty byte-array character sequence. */ public ByteArrayCharSequence() { this(ByteArrays.EMPTY_ARRAY); }
Example 2
Source File: CustomByteArrayFrontCodedList.java From database with GNU General Public License v2.0 | 4 votes |
public CustomByteArrayFrontCodedList(final Iterator<byte[]> arrays, final int ratio, final boolean hasDups) { assertRatio(ratio); // if (ratio < 1) // throw new IllegalArgumentException("Illegal ratio (" + ratio + ")"); byte[] array = ByteArrays.EMPTY_ARRAY; int[] p = IntArrays.EMPTY_ARRAY; byte[][] a = new byte[2][]; int curSize = 0, b = 0, common, length, minLength; while (arrays.hasNext()) { a[b] = (byte[]) arrays.next(); length = a[b].length; if (n % ratio == 0) { p = IntArrays.grow(p, n / ratio + 1); p[n / ratio] = curSize; array = ByteArrays.grow(array, curSize + count(length) + length, curSize); curSize += writeInt(array, length, curSize); System.arraycopy(a[b], 0, array, curSize, length); curSize += length; } else { minLength = a[1 - b].length; if (length < minLength) minLength = length; for (common = 0; common < minLength; common++) if (a[0][common] != a[1][common]) break; length -= common; array = ByteArrays.grow(array, curSize + count(length) + count(common) + length, curSize); curSize += writeInt(array, length, curSize); curSize += writeInt(array, common, curSize); System.arraycopy(a[b], common, array, curSize, length); curSize += length; } b = 1 - b; n++; } this.ratio = ratio; // this.array = ByteArrays.trim(array, curSize); this.bb = new BackingByteArray( ByteArrays.trim(array, curSize) ); // this.bb = new BackingByteBuffer( ByteBuffer.wrap(ByteArrays.trim(array, curSize) )); this.p = IntArrays.trim(p, (n + ratio - 1) / ratio); this.hasDups = hasDups; }
Example 3
Source File: CustomByteArrayFrontCodedList.java From database with GNU General Public License v2.0 | 4 votes |
public ObjectListIterator<byte[]> listIterator(final int start) { ensureIndex(start); return new AbstractObjectListIterator<byte[]>() { byte a[] = ByteArrays.EMPTY_ARRAY; int i = 0, pos = 0; boolean inSync; // Whether the current value in a is the string just // before the next to be produced. { if (start != 0) { if (start == n) i = start; // If we start at the end, we do nothing. else { pos = p[start / ratio]; int j = start % ratio; i = start - j; while (j-- != 0) next(); } } } public boolean hasNext() { return i < n; } public boolean hasPrevious() { return i > 0; } public int previousIndex() { return i - 1; } public int nextIndex() { return i; } public byte[] next() { int length, common; if (!hasNext()) throw new NoSuchElementException(); final BackingBuffer bb = CustomByteArrayFrontCodedList.this.bb; if (i % ratio == 0) { pos = p[i / ratio]; // length = readInt(array, pos); length = bb.readInt(pos); a = ByteArrays.ensureCapacity(a, length, 0); // System.arraycopy(array, pos + count(length), a, 0, length); bb.arraycopy(pos + count(length), a, 0, length); pos += length + count(length); inSync = true; } else { if (inSync) { // length = readInt(array, pos); // common = readInt(array, pos + count(length)); length = bb.readInt(pos); common = bb.readInt(pos + count(length)); a = ByteArrays.ensureCapacity(a, length + common, common); // System.arraycopy(array, pos + count(length) // + count(common), a, common, length); bb.arraycopy(pos + count(length) + count(common), a, common, length); pos += count(length) + count(common) + length; length += common; } else { a = ByteArrays.ensureCapacity(a, length = length(i), 0); extract(i, a, 0, length); } } i++; return ByteArrays.copy(a, 0, length); } public byte[] previous() { if (!hasPrevious()) throw new NoSuchElementException(); inSync = false; return getArray(--i); } }; }