Package org.terrier.compression.bit
Class LinkedBuffer
- java.lang.Object
-
- org.terrier.compression.bit.LinkedBuffer
-
public class LinkedBuffer extends java.lang.ObjectImplements an element of a linked list that contains a byte array- Author:
- Roi Blanco
-
-
Field Summary
Fields Modifier and Type Field Description protected byte[]bufferThe internal buffer.protected intbufferSizeThe size of the internal bufferstatic intDEFAULT_BUFFER_SIZEThe default size of the internal buffer in bytes The buffer has to be big enough to allocate a single write, i.e we cannot write *at once* more than bufferSize bytesprotected LinkedBuffernextThe next buffer in the list
-
Constructor Summary
Constructors Constructor Description LinkedBuffer()Default Constructor.LinkedBuffer(int _bufferSize)Constructor
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description byte[]getBuffer()intgetBufferSize()LinkedBuffergetNext()intgetPosition()voidsetNext(LinkedBuffer _next)Set the next buffer in the listbooleanwrite(int b)Writes a byte in the bufferbooleanwriteByte(byte b)Writes a byte in the buffer
-
-
-
Field Detail
-
buffer
protected byte[] buffer
The internal buffer.
-
bufferSize
protected int bufferSize
The size of the internal buffer
-
DEFAULT_BUFFER_SIZE
public static final int DEFAULT_BUFFER_SIZE
The default size of the internal buffer in bytes The buffer has to be big enough to allocate a single write, i.e we cannot write *at once* more than bufferSize bytes- See Also:
- Constant Field Values
-
next
protected LinkedBuffer next
The next buffer in the list
-
-
Method Detail
-
getNext
public LinkedBuffer getNext()
- Returns:
- the next linked buffer in the list (or null)
-
setNext
public void setNext(LinkedBuffer _next)
Set the next buffer in the list- Parameters:
_next- next LinkedBuffer in the list
-
write
public boolean write(int b) throws java.io.IOExceptionWrites a byte in the buffer- Parameters:
b- int containing the byte to write- Returns:
- true iff the buffer has used all its capacity
- Throws:
java.io.IOException
-
writeByte
public boolean writeByte(byte b) throws java.io.IOExceptionWrites a byte in the buffer- Parameters:
b- byte to write- Returns:
- true iff the buffer has used all its capacity
- Throws:
java.io.IOException
-
getBufferSize
public int getBufferSize()
- Returns:
- The size of the buffer
-
getPosition
public int getPosition()
- Returns:
- The current position in the buffer
-
getBuffer
public byte[] getBuffer()
- Returns:
- The byte buffer (byte[])
-
-