public static LongBuffer shapeOf(LongBuffer buffer) { Buffer buffer2 = (Buffer) buffer; val ret = (LongBuffer) buffer2.position(1); return ret.slice(); }
public static LongBuffer stride(LongBuffer buffer) { int rank = rank(buffer); val buffer2 = (Buffer) buffer; val ret = (LongBuffer) buffer2.position(1 + rank); return ret.slice(); }
@Override public LongBuffer sliceBuffer(LongBuffer buffer) { return buffer.slice(); }
@Override public LongBuffer sliceBuffer(LongBuffer buffer) { return buffer.slice(); }
private LongBuffer copy(LongBuffer a, int i) { a.position(i); return a.slice(); }
private LongBuffer copy(LongBuffer a, int i) { a.position(i); return a.slice(); }
public LongBuffer slice() { return buf.get().slice(); }
/** * Construct a ImmutableBitSet from the content of the LongBuffer * which should have been initialized with BitSet.serialize (from the BitSet in this * same package). * * The input is not modified. * * @param bs the data source */ public ImmutableBitSet(final LongBuffer bs) { int length = (int) bs.get(0); LongBuffer copy = bs.slice(); copy.position(1); data = copy.slice(); data.limit(length); }
/** * Construct a ImmutableBitSet from the content of the LongBuffer * which should have been initialized with BitSet.serialize (from the BitSet in this * same package). * * The input is not modified. * * @param bs the data source */ public ImmutableBitSet(final LongBuffer bs) { int length = (int) bs.get(0); LongBuffer copy = bs.slice(); copy.position(1); data = copy.slice(); data.limit(length); }
/** * Returns a new immutable bit set containing all the bits in the given long * buffer. */ public static ImmutableBitSet valueOf(LongBuffer longs) { longs = longs.slice(); int n = longs.remaining(); while (n > 0 && longs.get(n - 1) == 0) { --n; } if (n == 0) { return EMPTY; } long[] words = new long[n]; longs.get(words); return new ImmutableBitSet(words); }
/** * Returns a new immutable bit set containing all the bits in the given long * buffer. */ public static ImmutableBitSet valueOf(LongBuffer longs) { longs = longs.slice(); int n = longs.remaining(); while (n > 0 && longs.get(n - 1) == 0) { --n; } if (n == 0) { return EMPTY; } long[] words = new long[n]; longs.get(words); return new ImmutableBitSet(words); }
/** * Creates a bitmap with the specified ByteBuffer backend. It assumes * that a bitmap was serialized at this location. It is effectively "deserialized" * though the actual content is not copied. * This might be useful for implementing memory-mapped bitmaps. * * @param buffer data source */ public EWAHCompressedBitmap(ByteBuffer buffer) { IntBuffer ib = buffer.asIntBuffer(); this.sizeInBits = ib.get(0); int sizeInWords = ib.get(1); int rlwposition = ib.get(2 + sizeInWords * 2); LongBuffer lb = buffer.asLongBuffer(); lb.position(1); this.buffer = new LongBufferWrapper(lb.slice(), sizeInWords); this.rlw = new RunningLengthWord(this.buffer, rlwposition); }
/** * Creates a bitmap with the specified ByteBuffer backend. It assumes * that a bitmap was serialized at this location. It is effectively "deserialized" * though the actual content is not copied. * This might be useful for implementing memory-mapped bitmaps. * * @param buffer data source */ public EWAHCompressedBitmap(ByteBuffer buffer) { IntBuffer ib = buffer.asIntBuffer(); this.sizeInBits = ib.get(0); int sizeInWords = ib.get(1); int rlwposition = ib.get(2 + sizeInWords * 2); LongBuffer lb = buffer.asLongBuffer(); lb.position(1); this.buffer = new LongBufferWrapper(lb.slice(), sizeInWords); this.rlw = new RunningLengthWord(this.buffer, rlwposition); }
/** * Returns a new bit set containing all the bits in the given long * buffer between its position and limit. * * <p>More precisely, * <br>{@code BitSet.valueOf(lb).get(n) == ((lb.get(lb.position()+n/64) & (1L<<(n%64))) != 0)} * <br>for all {@code n < 64 * lb.remaining()}. * * <p>The long buffer is not modified by this method, and no * reference to the buffer is retained by the bit set. * * @param lb a long buffer containing a little-endian representation * of a sequence of bits between its position and limit, to be * used as the initial bits of the new bit set * @return a new bit set containing all the bits in the given long buffer between its position and limit * @since 1.7 */ public static BitSet valueOf(LongBuffer lb) { lb = lb.slice(); int n; for (n = lb.remaining(); n > 0 && lb.get(n - 1) == 0; n--) ; long[] words = new long[n]; lb.get(words); return new BitSet(words); }
/** * Returns a new bit set containing all the bits in the given long * buffer between its position and limit. * * <p>More precisely, * <br>{@code BitSet.valueOf(lb).get(n) == ((lb.get(lb.position()+n/64) & (1L<<(n%64))) != 0)} * <br>for all {@code n < 64 * lb.remaining()}. * * <p>The long buffer is not modified by this method, and no * reference to the buffer is retained by the bit set. * * @param lb a long buffer containing a little-endian representation * of a sequence of bits between its position and limit, to be * used as the initial bits of the new bit set * @since 1.7 */ public static BitSet valueOf(LongBuffer lb) { lb = lb.slice(); int n; for (n = lb.remaining(); n > 0 && lb.get(n - 1) == 0; n--) ; long[] words = new long[n]; lb.get(words); return new BitSet(words); }
/** * Place holder for {@code Buffer.slice()}. * * @param b the buffer to slice. * @return the sliced buffer. */ public static Buffer slice(Buffer b) { if (b instanceof ByteBuffer) return ((ByteBuffer) b).slice(); if (b instanceof ShortBuffer) return ((ShortBuffer) b).slice(); if (b instanceof IntBuffer) return ((IntBuffer) b).slice(); if (b instanceof LongBuffer) return ((LongBuffer) b).slice(); if (b instanceof FloatBuffer) return ((FloatBuffer) b).slice(); if (b instanceof DoubleBuffer) return ((DoubleBuffer) b).slice(); throw new IllegalArgumentException(); } }
/** * Calls slice on the specified buffer while maintaining the byteorder. * @see #slice(java.nio.Buffer, int, int) */ @SuppressWarnings("unchecked") public static <B extends Buffer> B slice(final B buffer) { if (buffer instanceof ByteBuffer) { final ByteBuffer bb = (ByteBuffer) buffer; return (B) bb.slice().order(bb.order()); // slice and duplicate may change byte order } else if (buffer instanceof IntBuffer) { return (B) ((IntBuffer) buffer).slice(); } else if (buffer instanceof ShortBuffer) { return (B) ((ShortBuffer) buffer).slice(); } else if (buffer instanceof FloatBuffer) { return (B) ((FloatBuffer) buffer).slice(); } else if (buffer instanceof DoubleBuffer) { return (B) ((DoubleBuffer) buffer).slice(); } else if (buffer instanceof LongBuffer) { return (B) ((LongBuffer) buffer).slice(); } else if (buffer instanceof CharBuffer) { return (B) ((CharBuffer) buffer).slice(); } throw new IllegalArgumentException("unexpected buffer type: " + buffer.getClass()); }
/** * Creates a new Pointer to the given buffer, taking into * account the position and array offset of the given buffer. * The buffer is assumed to be non-<code>null</code>, and * be either direct or have a backing array. * * @param buffer The buffer * @return The pointer */ private static Pointer computePointer(LongBuffer buffer) { Pointer result = null; if (buffer.isDirect()) { int oldPosition = buffer.position(); buffer.position(0); result = Pointer.to(buffer.slice()).withByteOffset( oldPosition * Sizeof.LONG); buffer.position(oldPosition); } else if (buffer.hasArray()) { LongBuffer t = LongBuffer.wrap(buffer.array()); int elementOffset = buffer.position() + buffer.arrayOffset(); result = Pointer.to(t).withByteOffset( elementOffset * Sizeof.LONG); } return result; }
/** * Creates a new Pointer to the given buffer, taking into * account the position and array offset of the given buffer. * The buffer is assumed to be non-<code>null</code>, and * be either direct or have a backing array. * * @param buffer The buffer * @return The pointer */ private static Pointer computePointer(LongBuffer buffer) { Pointer result = null; if (buffer.isDirect()) { int oldPosition = buffer.position(); buffer.position(0); result = Pointer.to(buffer.slice()).withByteOffset( oldPosition * Sizeof.LONG); buffer.position(oldPosition); } else if (buffer.hasArray()) { LongBuffer t = LongBuffer.wrap(buffer.array()); int elementOffset = buffer.position() + buffer.arrayOffset(); result = Pointer.to(t).withByteOffset( elementOffset * Sizeof.LONG); } return result; }