/** * Removes the first (oldest/head) byte in the buffer. If the buffer is empty, * this method will throw a BufferIsEmptyException * @return The first (oldest/head) byte in the buffer * @throws BufferIsEmptyException If the buffer is empty and a byte cannot be * removed. */ public byte remove() throws BufferIsEmptyException { if (size() == 0) { throw new BufferIsEmptyException("Buffer is empty and no bytes available to remove"); } byte b = this.buffer[this.currentReadPosition]; this.currentReadPosition = (this.currentReadPosition + 1) % this.buffer.length; this.currentBufferSize -= 1; return b; }
/** * Removes the first (oldest/head) byte in the buffer. If the buffer is empty, * this method will throw a BufferIsEmptyException * @return The first (oldest/head) byte in the buffer * @throws BufferIsEmptyException If the buffer is empty and a byte cannot be * removed. */ public byte remove() throws BufferIsEmptyException { if (size() == 0) { throw new BufferIsEmptyException("Buffer is empty and no bytes available to remove"); } byte b = this.buffer[this.currentReadPosition]; this.currentReadPosition = (this.currentReadPosition + 1) % this.buffer.length; this.currentBufferSize -= 1; return b; }