/** * Returns this list's capacity. * * @return the capacity of the list. */ public int capacity() { return listBuffer.getInt(capacityOffset()); }
/** * Returns this list's capacity. * * @return the capacity of the list. */ public int capacity() { return listBuffer.getInt(capacityOffset()); }
public CompactList(AllocatedBuffer allocatedBuffer, int elementMaxLength, int capacity) { this.allocatedBuffer = allocatedBuffer; framedElementLength = framedLength(elementMaxLength); final int requiredBufferCapacity = requiredBufferCapacity(framedElementLength, capacity); final int bufferCapacity = allocatedBuffer.capacity(); if (bufferCapacity < requiredBufferCapacity) { final String errorMessage = String.format( "Not enough capacity in provided buffer. Has %d, required %d", bufferCapacity, requiredBufferCapacity); throw new IllegalArgumentException(errorMessage); } listBuffer = new UnsafeBuffer(0, 0); listBuffer.wrap(allocatedBuffer.getRawBuffer(), 0, requiredBufferCapacity); // write header listBuffer.putInt(sizeOffset(), 0); listBuffer.putInt(elementMaxLengthOffset(), elementMaxLength); listBuffer.putInt(capacityOffset(), capacity); iterator = new CompactListIterator(this); }
public CompactList(AllocatedBuffer allocatedBuffer, int elementMaxLength, int capacity) { this.allocatedBuffer = allocatedBuffer; framedElementLength = framedLength(elementMaxLength); final int requiredBufferCapacity = requiredBufferCapacity(framedElementLength, capacity); final int bufferCapacity = allocatedBuffer.capacity(); if (bufferCapacity < requiredBufferCapacity) { final String errorMessage = String.format( "Not enough capacity in provided buffer. Has %d, required %d", bufferCapacity, requiredBufferCapacity); throw new IllegalArgumentException(errorMessage); } listBuffer = new UnsafeBuffer(0, 0); listBuffer.wrap(allocatedBuffer.getRawBuffer(), 0, requiredBufferCapacity); // write header listBuffer.putInt(sizeOffset(), 0); listBuffer.putInt(elementMaxLengthOffset(), elementMaxLength); listBuffer.putInt(capacityOffset(), capacity); iterator = new CompactListIterator(this); }