@Override public CompactListIterator iterator() { iterator.reset(); return iterator; }
public CompactList(final UnsafeBuffer listBuffer) { this.listBuffer = listBuffer; final int elementMaxLength = listBuffer.getInt(elementMaxLengthOffset()); framedElementLength = framedLength(elementMaxLength); iterator = new CompactListIterator(this); this.allocatedBuffer = null; }
public CompactList(final UnsafeBuffer listBuffer) { this.listBuffer = listBuffer; final int elementMaxLength = listBuffer.getInt(elementMaxLengthOffset()); framedElementLength = framedLength(elementMaxLength); iterator = new CompactListIterator(this); this.allocatedBuffer = null; }
@Override public CompactListIterator iterator() { iterator.reset(); return iterator; }
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 CompactListIterator(final CompactList values) { this.values = values; this.current = new UnsafeBuffer(new byte[values.maxElementDataLength()]); reset(); }
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 CompactListIterator(final CompactList values) { this.values = values; this.current = new UnsafeBuffer(new byte[values.maxElementDataLength()]); reset(); }