/** * {@inheritDoc} */ @Override public void free() { while (!bas.isEmpty()) { Node node = bas.getLast(); node.getByteArray().free(); bas.removeLast(); } }
/** * Removes the first node from this list * * @return * The node that was removed */ public Node removeFirst() { Node node = header.getNextNode(); firstByte += node.ba.last(); return removeNode(node); }
/** * @return the first {@link ByteArray} in the list */ public ByteArray getFirst() { if (bas.isEmpty()) { return null; } return bas.getFirst().getByteArray(); }
/** * Removes the last node in this list * * @return * The node that was taken off of the list */ public Node removeLast() { Node node = header.getPreviousNode(); lastByte -= node.ba.last(); return removeNode(node); }
/** * {@inheritDoc} */ @Override public void put(byte b) { prepareForAccess(1); componentCursor.put(b); index += 1; }
/** * {@inheritDoc} */ @Override public void putInt(int i) { prepareForAccess(4); cursor.putInt(i); }
/** * {@inheritDoc} */ @Override public void putFloat(float f) { prepareForAccess(4); cursor.putFloat(f); }
@Override protected void cursorPassedFirstComponent() { if (autoFree) { cba.removeFirst().free(); } }
/** * Removes the last {@link ByteArray} in the list * * @return The ByteArray that was removed */ public ByteArray removeLast() { Node node = bas.removeLast(); return node == null ? null : node.getByteArray(); }
/** * {@inheritDoc} */ @Override public byte get() { prepareForAccess(1); byte b = componentCursor.get(); index += 1; return b; }