Class Buffer
A buffer is a list of elements of a specific primitive type.
A buffer can be described by the following properties:
- Capacity: The number of elements a buffer can hold. Capacity may not be negative and never changes.
- Position: A cursor of this buffer. Elements are read or written at the position if you do not specify an index explicitly. Position may not be negative and not greater than the limit.
-
Limit:
Controls the scope of accessible elements. You can only read or
write elements from index zero to
limit - 1
. Accessing elements out of the scope will cause an exception. Limit may not be negative and not greater than capacity. - Mark: Used to remember the current position, so that you can reset the position later. Mark may not be negative and no greater than position.
- A buffer can be read-only or read-write. Trying to modify the elements of a read-only buffer will cause a ReadOnlyBufferException, while changing the position, limit and mark of a read-only buffer is OK.
- A buffer can be direct or indirect. A direct buffer will try its best to take advantage of native memory APIs and it may not stay in the heap, thus it is not affected by garbage collection.
Buffers are not thread-safe. If concurrent access to a buffer instance is required, then the callers are responsible to take care of the synchronization issues.
Inheritance
Assembly: DistributedLucene.Net.dll
Syntax
public abstract class Buffer : object
Properties
Name | Description |
---|---|
Capacity | Returns the capacity of this buffer. |
HasRemaining | Indicates if there are elements remaining in this buffer, that is if
|
IsReadOnly | Indicates whether this buffer is read-only. |
Limit | Gets or Sets the limit of this buffer. |
Position | Returns the position of this buffer. |
Remaining | Returns the number of remaining elements in this buffer, that is
|
Methods
Name | Description |
---|---|
Clear() | Clears this buffer. While the content of this buffer is not changed, the following internal changes take place: the current position is reset back to the start of the buffer, the value of the buffer limit is made equal to the capacity and mark is cleared. |
Flip() | Flips this buffer. The limit is set to the current position, then the position is set to zero, and the mark is cleared. The content of this buffer is not changed. |
Mark() | Marks the current position, so that the position may return to this point later by calling Reset(). |
Reset() | Resets the position of this buffer to the Lucene.Net.Support.IO.Buffer.mark. |
Rewind() | Rewinds this buffer. The position is set to zero, and the mark is cleared. The content of this] buffer is not changed. |
SetLimit(Int32) | Sets the limit of this buffer.
If the current position in the buffer is in excess of
|
SetPosition(Int32) | Sets the position of this buffer. If the mark is set and it is greater than the new position, then it is cleared. |