Class ByteBuffer
A buffer for bytes.
A byte buffer can be created in either one of the following ways:
- Allocate(Int32) a new byte array and create a buffer based on it
- AllocateDirect(Int32) a memory block and create a direct buffer based on it
- Wrap(Byte[]) an existing byte array to create a new buffer
Implements
Inherited Members
Namespace: Lucene.Net.Support.IO
Assembly: Lucene.Net.dll
Syntax
public abstract class ByteBuffer : Buffer, IComparable<ByteBuffer>
Properties
| Improve this Doc View SourceArray
Returns the byte array which this buffer is based on, if there is one.
Declaration
public byte[] Array { get; }
Property Value
Type | Description |
---|---|
System.Byte[] | the byte array which this buffer is based on. |
Exceptions
Type | Condition |
---|---|
ReadOnlyBufferException | if this buffer is based on a read-only array. |
System.InvalidOperationException | if this buffer is not based on an array. |
ArrayOffset
Returns the offset of the byte array which this buffer is based on, if there is one.
The offset is the index of the array which corresponds to the zero position of the buffer.
Declaration
public int ArrayOffset { get; }
Property Value
Type | Description |
---|---|
System.Int32 |
Exceptions
Type | Condition |
---|---|
ReadOnlyBufferException | if this buffer is based on a read-only array. |
System.InvalidOperationException | if this buffer is not based on an array. |
HasArray
Indicates whether this buffer is based on a byte array and provides read/write access.
Declaration
public bool HasArray { get; }
Property Value
Type | Description |
---|---|
System.Boolean |
IsDirect
Indicates whether this buffer is direct.
Declaration
public abstract bool IsDirect { get; }
Property Value
Type | Description |
---|---|
System.Boolean |
Order
Returns the byte order used by this buffer when converting bytes from/to other primitive types.
The default byte order of byte buffer is always BIG_ENDIAN.
Declaration
public ByteOrder Order { get; set; }
Property Value
Type | Description |
---|---|
ByteOrder |
ProtectedArray
Child class implements this method to realize Array.
Declaration
protected abstract byte[] ProtectedArray { get; }
Property Value
Type | Description |
---|---|
System.Byte[] |
See Also
| Improve this Doc View SourceProtectedArrayOffset
Child class implements this method to realize ArrayOffset.
Declaration
protected abstract int ProtectedArrayOffset { get; }
Property Value
Type | Description |
---|---|
System.Int32 |
ProtectedHasArray
Child class implements this method to realize HasArray.
Declaration
protected abstract bool ProtectedHasArray { get; }
Property Value
Type | Description |
---|---|
System.Boolean |
Methods
| Improve this Doc View SourceAllocate(Int32)
Creates a byte buffer based on a newly allocated byte array.
Declaration
public static ByteBuffer Allocate(int capacity)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | capacity | the capacity of the new buffer |
Returns
Type | Description |
---|---|
ByteBuffer | The created byte buffer. |
Exceptions
Type | Condition |
---|---|
System.ArgumentException | If the |
AllocateDirect(Int32)
Creates a direct byte buffer based on a newly allocated memory block. (NOT IMPLEMENTED IN LUCENE.NET)
Declaration
public static ByteBuffer AllocateDirect(int capacity)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | capacity | the capacity of the new buffer |
Returns
Type | Description |
---|---|
ByteBuffer | The new byte buffer |
Exceptions
Type | Condition |
---|---|
System.ArgumentException | If the |
AsInt64Buffer()
Returns a long buffer which is based on the remaining content of this byte buffer.
The new buffer's position is zero, its limit and capacity is the number of remaining bytes divided by eight, and its mark is not set. The new buffer's read-only property and byte order are the same as this buffer's. The new buffer is direct if this byte buffer is direct.
The new buffer shares its content with this buffer, which means either buffer's change of content will be visible to the other. The two buffer's position, limit and mark are independent.
Declaration
public abstract Int64Buffer AsInt64Buffer()
Returns
Type | Description |
---|---|
Int64Buffer | a long buffer which is based on the content of this byte buffer. |
AsReadOnlyBuffer()
Returns a read-only buffer that shares its content with this buffer.
The returned buffer is guaranteed to be a new instance, even if this buffer is read-only itself. The new buffer's position, limit, capacity and mark are the same as this buffer.
The new buffer shares its content with this buffer, which means this buffer's change of content will be visible to the new buffer. The two buffer's position, limit and mark are independent.
Declaration
public abstract ByteBuffer AsReadOnlyBuffer()
Returns
Type | Description |
---|---|
ByteBuffer | a read-only version of this buffer. |
Compact()
Compacts this byte buffer.
The remaining bytes will be moved to the head of the buffer, starting from position zero. Then the position is set to Remaining; the limit is set to capacity; the mark is cleared.
Declaration
public abstract ByteBuffer Compact()
Returns
Type | Description |
---|---|
ByteBuffer | this buffer. |
Exceptions
Type | Condition |
---|---|
ReadOnlyBufferException | if no changes may be made to the contents of this buffer. |
CompareTo(ByteBuffer)
Compares the remaining bytes of this buffer to another byte buffer's remaining bytes.
Declaration
public virtual int CompareTo(ByteBuffer otherBuffer)
Parameters
Type | Name | Description |
---|---|---|
ByteBuffer | otherBuffer | another byte buffer. |
Returns
Type | Description |
---|---|
System.Int32 | a negative value if this is less than |
Duplicate()
Returns a duplicated buffer that shares its content with this buffer.
The duplicated buffer's position, limit, capacity and mark are the same as this buffer's. The duplicated buffer's read-only property and byte order are the same as this buffer's too.
The new buffer shares its content with this buffer, which means either buffer's change of content will be visible to the other. The two buffer's position, limit and mark are independent.
Declaration
public abstract ByteBuffer Duplicate()
Returns
Type | Description |
---|---|
ByteBuffer | a duplicated buffer that shares its content with this buffer. |
Equals(Object)
Checks whether this byte buffer is equal to another object.
If other
is not a byte buffer then false
is returned. Two
byte buffers are equal if and only if their remaining bytes are exactly
the same. Position, limit, capacity and mark are not considered.
Declaration
public override bool Equals(object other)
Parameters
Type | Name | Description |
---|---|---|
System.Object | other | the object to compare with this byte buffer. |
Returns
Type | Description |
---|---|
System.Boolean |
|
Overrides
Get()
Returns the byte at the current position and increases the position by 1.
Declaration
public abstract byte Get()
Returns
Type | Description |
---|---|
System.Byte | the byte at the current position. |
Exceptions
Type | Condition |
---|---|
BufferUnderflowException | if the position is equal or greater than limit. |
Get(Byte[])
Reads bytes from the current position into the specified byte array and increases the position by the number of bytes read.
Calling this method has the same effect as
Get(dest, 0, dest.Length)
.
Declaration
public virtual ByteBuffer Get(byte[] dest)
Parameters
Type | Name | Description |
---|---|---|
System.Byte[] | dest | the destination byte array. |
Returns
Type | Description |
---|---|
ByteBuffer | this buffer. |
Exceptions
Type | Condition |
---|---|
BufferUnderflowException | if |
Get(Byte[], Int32, Int32)
Reads bytes from the current position into the specified byte array, starting at the specified offset, and increases the position by the number of bytes read.
Declaration
public virtual ByteBuffer Get(byte[] dest, int off, int len)
Parameters
Type | Name | Description |
---|---|---|
System.Byte[] | dest | the target byte array. |
System.Int32 | off | the offset of the byte array, must not be negative and
not greater than |
System.Int32 | len | the number of bytes to read, must not be negative and not
greater than |
Returns
Type | Description |
---|---|
ByteBuffer | this buffer. |
Exceptions
Type | Condition |
---|---|
System.IndexOutOfRangeException | if either |
BufferUnderflowException | if |
Get(Int32)
Returns the byte at the specified index and does not change the position.
Declaration
public abstract byte Get(int index)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | index | the index, must not be negative and less than limit. |
Returns
Type | Description |
---|---|
System.Byte | the byte at the specified index. |
Exceptions
Type | Condition |
---|---|
System.IndexOutOfRangeException | if index is invalid. |
GetChar()
Returns the char at the current position and increases the position by 2.
The 2 bytes starting at the current position are composed into a char according to the current byte order and returned.
Declaration
public abstract char GetChar()
Returns
Type | Description |
---|---|
System.Char | the char at the current position. |
Exceptions
Type | Condition |
---|---|
BufferUnderflowException | if the position is greater than |
GetChar(Int32)
Returns the char at the specified index.
The 2 bytes starting from the specified index are composed into a char according to the current byte order and returned. The position is not changed.
Declaration
public abstract char GetChar(int index)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | index | the index, must not be negative and equal or less than |
Returns
Type | Description |
---|---|
System.Char | the char at the specified index. |
Exceptions
Type | Condition |
---|---|
System.IndexOutOfRangeException | if |
GetDouble()
Returns the double at the current position and increases the position by 8.
The 8 bytes starting from the current position are composed into a double according to the current byte order and returned.
Declaration
public abstract double GetDouble()
Returns
Type | Description |
---|---|
System.Double | the double at the current position. |
Exceptions
Type | Condition |
---|---|
BufferUnderflowException | if the position is greater than |
GetDouble(Int32)
Returns the System.Double at the specified index.
The 8 bytes starting at the specified index are composed into a System.Double according to the current byte order and returned. The position is not changed.
Declaration
public abstract double GetDouble(int index)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | index | the index, must not be negative and equal or less than |
Returns
Type | Description |
---|---|
System.Double | the System.Double at the specified index. |
Exceptions
Type | Condition |
---|---|
System.IndexOutOfRangeException | if |
GetHashCode()
Calculates this buffer's hash code from the remaining chars. The position, limit, capacity and mark don't affect the hash code.
Declaration
public override int GetHashCode()
Returns
Type | Description |
---|---|
System.Int32 | the hash code calculated from the remaining bytes. |
Overrides
GetInt16()
Returns the System.Int16 at the current position and increases the position by 2.
The 2 bytes starting at the current position are composed into a System.Int16 according to the current byte order and returned.
NOTE: This was getShort() in the JDK
Declaration
public abstract short GetInt16()
Returns
Type | Description |
---|---|
System.Int16 | the System.Int16 at the current position. |
Exceptions
Type | Condition |
---|---|
BufferUnderflowException | if the position is greater than |
GetInt16(Int32)
Returns the System.Int16 at the specified index.
The 2 bytes starting at the specified index are composed into a System.Int16 according to the current byte order and returned. The position is not changed.
NOTE: This was getShort() in the JDK
Declaration
public abstract short GetInt16(int index)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | index | the index, must not be negative and equal or less than |
Returns
Type | Description |
---|---|
System.Int16 | the System.Int16 at the specified index. |
Exceptions
Type | Condition |
---|---|
System.IndexOutOfRangeException | if |
GetInt32()
Returns the System.Int32 at the current position and increases the position by 4.
The 4 bytes starting at the current position are composed into a System.Int32 according to the current byte order and returned.
NOTE: This was getInt() in the JDK
Declaration
public abstract int GetInt32()
Returns
Type | Description |
---|---|
System.Int32 | the System.Int32 at the current position. |
Exceptions
Type | Condition |
---|---|
BufferUnderflowException | if the position is greater than |
GetInt32(Int32)
Returns the System.Int32 at the specified index.
The 4 bytes starting at the specified index are composed into a System.Int32 according to the current byte order and returned. The position is not changed.
NOTE: This was getInt() in the JDK
Declaration
public abstract int GetInt32(int index)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | index | the index, must not be negative and equal or less than |
Returns
Type | Description |
---|---|
System.Int32 | the System.Int32 at the specified index. |
Exceptions
Type | Condition |
---|---|
System.IndexOutOfRangeException | if |
GetInt64()
Returns the System.Int64 at the current position and increases the position by 8.
The 8 bytes starting at the current position are composed into a System.Int64 according to the current byte order and returned.
NOTE: This was getLong() in the JDK
Declaration
public abstract long GetInt64()
Returns
Type | Description |
---|---|
System.Int64 | the System.Int64 at the current position. |
Exceptions
Type | Condition |
---|---|
BufferUnderflowException | if the position is greater than |
GetInt64(Int32)
Returns the System.Int64 at the specified index.
The 8 bytes starting at the specified index are composed into a System.Int64 according to the current byte order and returned. The position is not changed.
NOTE: This was getLong() in the JDK
Declaration
public abstract long GetInt64(int index)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | index | the index, must not be negative and equal or less than |
Returns
Type | Description |
---|---|
System.Int64 | the System.Int64 at the specified index. |
Exceptions
Type | Condition |
---|---|
System.IndexOutOfRangeException | if |
GetSingle()
Returns the System.Single at the current position and increases the position by 4.
The 4 bytes starting at the current position are composed into a System.Single according to the current byte order and returned.
NOTE: This was getFloat() in the JDK
Declaration
public abstract float GetSingle()
Returns
Type | Description |
---|---|
System.Single | the System.Single at the current position. |
Exceptions
Type | Condition |
---|---|
BufferUnderflowException | if the position is greater than |
GetSingle(Int32)
Returns the System.Single at the specified index.
The 4 bytes starting at the specified index are composed into a System.Single according to the current byte order and returned. The position is not changed.
NOTE: This was getFloat() in the JDK
Declaration
public abstract float GetSingle(int index)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | index | the index, must not be negative and equal or less than |
Returns
Type | Description |
---|---|
System.Single | the System.Single at the specified index. |
Exceptions
Type | Condition |
---|---|
System.IndexOutOfRangeException | if |
Put(ByteBuffer)
Writes all the remaining bytes of the src
byte buffer to this
buffer's current position, and increases both buffers' position by the
number of bytes copied.
Declaration
public virtual ByteBuffer Put(ByteBuffer src)
Parameters
Type | Name | Description |
---|---|---|
ByteBuffer | src | the source byte buffer. |
Returns
Type | Description |
---|---|
ByteBuffer | this buffer. |
Exceptions
Type | Condition |
---|---|
BufferOverflowException | if |
System.ArgumentException | if |
ReadOnlyBufferException | if no changes may be made to the contents of this buffer. |
Put(Byte)
Writes the given byte to the current position and increases the position by 1.
Declaration
public abstract ByteBuffer Put(byte b)
Parameters
Type | Name | Description |
---|---|---|
System.Byte | b | the byte to write. |
Returns
Type | Description |
---|---|
ByteBuffer | this buffer. |
Exceptions
Type | Condition |
---|---|
BufferOverflowException | if position is equal or greater than limit. |
ReadOnlyBufferException | if no changes may be made to the contents of this buffer. |
Put(Byte[])
Writes bytes in the given byte array to the current position and increases the position by the number of bytes written.
Calling this method has the same effect as
Put(src, 0, src.Length)
.
Declaration
public ByteBuffer Put(byte[] src)
Parameters
Type | Name | Description |
---|---|---|
System.Byte[] | src | the source byte array. |
Returns
Type | Description |
---|---|
ByteBuffer | this buffer. |
Exceptions
Type | Condition |
---|---|
BufferOverflowException | if Remaining is less than |
ReadOnlyBufferException | if no changes may be made to the contents of this buffer. |
Put(Byte[], Int32, Int32)
Writes bytes in the given byte array, starting from the specified offset, to the current position and increases the position by the number of bytes written.
Declaration
public virtual ByteBuffer Put(byte[] src, int off, int len)
Parameters
Type | Name | Description |
---|---|---|
System.Byte[] | src | the source byte array. |
System.Int32 | off | the offset of byte array, must not be negative and not greater
than |
System.Int32 | len | the number of bytes to write, must not be negative and not
greater than |
Returns
Type | Description |
---|---|
ByteBuffer | this buffer. |
Exceptions
Type | Condition |
---|---|
BufferOverflowException | if Remaining is less than |
System.IndexOutOfRangeException | if either |
ReadOnlyBufferException | if no changes may be made to the contents of this buffer. |
Put(Int32, Byte)
Write a System.Byte to the specified index of this buffer without changing the position.
Declaration
public abstract ByteBuffer Put(int index, byte b)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | index | the index, must not be negative and less than the limit. |
System.Byte | b | the System.Byte to write. |
Returns
Type | Description |
---|---|
ByteBuffer | this buffer. |
Exceptions
Type | Condition |
---|---|
System.IndexOutOfRangeException | if |
ReadOnlyBufferException | if no changes may be made to the contents of this buffer. |
PutChar(Char)
Writes the given System.Char to the current position and increases the position by 2.
The System.Char is converted to bytes using the current byte order.
Declaration
public abstract ByteBuffer PutChar(char value)
Parameters
Type | Name | Description |
---|---|---|
System.Char | value | the System.Char to write. |
Returns
Type | Description |
---|---|
ByteBuffer | this buffer. |
Exceptions
Type | Condition |
---|---|
BufferOverflowException | if position is greater than |
ReadOnlyBufferException | if no changes may be made to the contents of this buffer. |
PutChar(Int32, Char)
Writes the given System.Char to the specified index of this buffer.
The System.Char is converted to bytes using the current byte order. The position is not changed.
Declaration
public abstract ByteBuffer PutChar(int index, char value)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | index | the index, must not be negative and equal or less than |
System.Char | value | the System.Char to write. |
Returns
Type | Description |
---|---|
ByteBuffer | this buffer. |
Exceptions
Type | Condition |
---|---|
System.IndexOutOfRangeException | if |
ReadOnlyBufferException | if no changes may be made to the contents of this buffer. |
PutDouble(Double)
Writes the given System.Double to the current position and increases the position by 8.
The System.Double is converted to bytes using the current byte order.
Declaration
public abstract ByteBuffer PutDouble(double value)
Parameters
Type | Name | Description |
---|---|---|
System.Double | value | the System.Double to write. |
Returns
Type | Description |
---|---|
ByteBuffer | this buffer. |
Exceptions
Type | Condition |
---|---|
BufferOverflowException | if position is greater than |
ReadOnlyBufferException | if no changes may be made to the contents of this buffer. |
PutDouble(Int32, Double)
Writes the given System.Double to the specified index of this buffer.
The System.Double is converted to bytes using the current byte order. The position is not changed.
Declaration
public abstract ByteBuffer PutDouble(int index, double value)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | index | the index, must not be negative and equal or less than |
System.Double | value | the System.Double to write. |
Returns
Type | Description |
---|---|
ByteBuffer |
Exceptions
Type | Condition |
---|---|
System.IndexOutOfRangeException | if |
ReadOnlyBufferException | if no changes may be made to the contents of this buffer. |
PutInt16(Int16)
Writes the given System.Int16 to the current position and increases the position by 2.
The System.Int16 is converted to bytes using the current byte order.
NOTE: This was putShort() in the JDK
Declaration
public abstract ByteBuffer PutInt16(short value)
Parameters
Type | Name | Description |
---|---|---|
System.Int16 | value | the System.Int16 to write. |
Returns
Type | Description |
---|---|
ByteBuffer | this buffer. |
Exceptions
Type | Condition |
---|---|
BufferOverflowException | if position is greater than |
ReadOnlyBufferException | if no changes may be made to the contents of this buffer. |
PutInt16(Int32, Int16)
Writes the given System.Int16 to the specified index of this buffer.
The System.Int16 is converted to bytes using the current byte order. The position is not changed.
NOTE: This was putShort() in the JDK
Declaration
public abstract ByteBuffer PutInt16(int index, short value)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | index | the index, must not be negative and equal or less than |
System.Int16 | value | the System.Int16 to write. |
Returns
Type | Description |
---|---|
ByteBuffer | this buffer. |
Exceptions
Type | Condition |
---|---|
System.IndexOutOfRangeException | if |
ReadOnlyBufferException | if no changes may be made to the contents of this buffer. |
PutInt32(Int32)
Writes the given System.Int32 to the current position and increases the position by 4.
The System.Int32 is converted to bytes using the current byte order.
NOTE: This was putInt() in the JDK
Declaration
public abstract ByteBuffer PutInt32(int value)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | value | the System.Int32 to write. |
Returns
Type | Description |
---|---|
ByteBuffer | this buffer. |
Exceptions
Type | Condition |
---|---|
BufferOverflowException | if position is greater than |
ReadOnlyBufferException | if no changes may be made to the contents of this buffer. |
PutInt32(Int32, Int32)
Writes the given System.Int32 to the specified index of this buffer.
The System.Int32 is converted to bytes using the current byte order. The position is not changed.
NOTE: This was putInt() in the JDK
Declaration
public abstract ByteBuffer PutInt32(int index, int value)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | index | the index, must not be negative and equal or less than |
System.Int32 | value | the System.Int32 to write. |
Returns
Type | Description |
---|---|
ByteBuffer | this buffer. |
Exceptions
Type | Condition |
---|---|
System.IndexOutOfRangeException | if |
ReadOnlyBufferException | if no changes may be made to the contents of this buffer. |
PutInt64(Int32, Int64)
Writes the given System.Int64 to the specified index of this buffer.
The System.Int64 is converted to bytes using the current byte order. The position is not changed.
NOTE: This was putLong() in the JDK
Declaration
public abstract ByteBuffer PutInt64(int index, long value)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | index | the index, must not be negative and equal or less than |
System.Int64 | value | the System.Int64 to write. |
Returns
Type | Description |
---|---|
ByteBuffer | this buffer. |
Exceptions
Type | Condition |
---|---|
System.IndexOutOfRangeException | if |
ReadOnlyBufferException | if no changes may be made to the contents of this buffer. |
PutInt64(Int64)
Writes the given System.Int64 to the current position and increases the position by 8.
The System.Int64 is converted to bytes using the current byte order.
NOTE: This was putLong() in the JDK
Declaration
public abstract ByteBuffer PutInt64(long value)
Parameters
Type | Name | Description |
---|---|---|
System.Int64 | value | the System.Int64 to write. |
Returns
Type | Description |
---|---|
ByteBuffer | this buffer. |
Exceptions
Type | Condition |
---|---|
BufferOverflowException | if position is greater than |
ReadOnlyBufferException | if no changes may be made to the contents of this buffer. |
PutSingle(Int32, Single)
Writes the given System.Single to the specified index of this buffer.
The System.Single is converted to bytes using the current byte order. The position is not changed.
NOTE: This was putSingle() in the JDK
Declaration
public abstract ByteBuffer PutSingle(int index, float value)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | index | the index, must not be negative and equal or less than |
System.Single | value | the System.Single to write. |
Returns
Type | Description |
---|---|
ByteBuffer |
Exceptions
Type | Condition |
---|---|
System.IndexOutOfRangeException | if |
ReadOnlyBufferException | if no changes may be made to the contents of this buffer. |
PutSingle(Single)
Writes the given System.Single to the current position and increases the position by 4.
The System.Single is converted to bytes using the current byte order.
NOTE: This was putSingle() in the JDK
Declaration
public abstract ByteBuffer PutSingle(float value)
Parameters
Type | Name | Description |
---|---|---|
System.Single | value | the System.Single to write. |
Returns
Type | Description |
---|---|
ByteBuffer | this buffer. |
Exceptions
Type | Condition |
---|---|
BufferOverflowException | if position is greater than |
ReadOnlyBufferException | if no changes may be made to the contents of this buffer. |
SetOrder(ByteOrder)
Sets the byte order of this buffer.
Declaration
public ByteBuffer SetOrder(ByteOrder byteOrder)
Parameters
Type | Name | Description |
---|---|---|
ByteOrder | byteOrder | the byte order to set. |
Returns
Type | Description |
---|---|
ByteBuffer | this buffer. |
Slice()
Returns a sliced buffer that shares its content with this buffer.
The sliced buffer's capacity will be this buffer's Remaining, and it's zero position will correspond to this buffer's current position. The new buffer's position will be 0, limit will be its capacity, and its mark is cleared. The new buffer's read-only property and byte order are the same as this buffer's.
The new buffer shares its content with this buffer, which means either buffer's change of content will be visible to the other. The two buffer's position, limit and mark are independent.
Declaration
public abstract ByteBuffer Slice()
Returns
Type | Description |
---|---|
ByteBuffer | A sliced buffer that shares its content with this buffer. |
ToString()
Returns a string representing the state of this byte buffer.
Declaration
public override string ToString()
Returns
Type | Description |
---|---|
System.String | A string representing the state of this byte buffer. |
Overrides
Wrap(Byte[])
Creates a new byte buffer by wrapping the given byte array.
Calling this method has the same effect as
Wrap(array, 0, array.Length)
.
Declaration
public static ByteBuffer Wrap(byte[] array)
Parameters
Type | Name | Description |
---|---|---|
System.Byte[] | array | The byte array which the new buffer will be based on |
Returns
Type | Description |
---|---|
ByteBuffer | The new byte buffer |
Wrap(Byte[], Int32, Int32)
Creates a new byte buffer by wrapping the given byte array.
The new buffer's position will be start
, limit will be
start + len
, capacity will be the length of the array.
Declaration
public static ByteBuffer Wrap(byte[] array, int start, int length)
Parameters
Type | Name | Description |
---|---|---|
System.Byte[] | array | The byte array which the new buffer will be based on. |
System.Int32 | start | The start index, must not be negative and not greater than |
System.Int32 | length | The length, must not be negative and not greater than
|
Returns
Type | Description |
---|---|
ByteBuffer | The new byte buffer |
Exceptions
Type | Condition |
---|---|
System.IndexOutOfRangeException | if either |