/** * Constructs a CompoundVecBuffer with the specified initial capacity. * * @param capacity the CompoundVecBuffer's initial capacity, in number of sub-buffers. * * @throws ArgumentException if the capacity is less than 1. */ public CompoundVecBuffer(int capacity) { if (capacity < 1) { String message = Logging.getMessage("generic.CapacityIsInvalid", capacity); Logging.logger().severe(message); throw new ArgumentException(message); } this.capacity = capacity; this.offsets = WWBufferUtil.newIntBuffer(capacity, ALLOCATE_DIRECT_BUFFERS); this.lengths = WWBufferUtil.newIntBuffer(capacity, ALLOCATE_DIRECT_BUFFERS); }
protected CompoundVecBuffer(CompoundVecBuffer that, int[] indices, int offset, int length) { this.count = length; this.capacity = length; this.offsets = WWBufferUtil.newIntBuffer(length, ALLOCATE_DIRECT_BUFFERS); this.lengths = WWBufferUtil.newIntBuffer(length, ALLOCATE_DIRECT_BUFFERS); for (int i = offset; i < offset + length; i++) { this.offsets.put(that.offsets.get(indices[i])); this.lengths.put(that.lengths.get(indices[i])); } this.offsets.rewind(); this.lengths.rewind(); }
protected CompoundVecBuffer(CompoundVecBuffer that, int beginIndex, int endIndex) { int length = endIndex - beginIndex + 1; this.count = length; this.capacity = length; this.offsets = WWBufferUtil.newIntBuffer(length, ALLOCATE_DIRECT_BUFFERS); that.offsets.limit(endIndex + 1); that.offsets.position(beginIndex); this.offsets.put(that.offsets); this.offsets.rewind(); that.offsets.clear(); this.lengths = WWBufferUtil.newIntBuffer(length, ALLOCATE_DIRECT_BUFFERS); that.lengths.limit(endIndex + 1); that.lengths.position(beginIndex); this.lengths.put(that.lengths); this.lengths.rewind(); that.lengths.clear(); }