ExpandableBuffer
ExpandableBuffer wraps around a bytearray object that can be extended in both direction, front & back
The valid bytes in the Buffer is between Head & Tail.
The current implementation of expandableBuffer is not threadsafe, and should not be used in multiple thread environment.
Constructors
Constructor | Description |
new(size, posAtZero)
Signature: (size:int * posAtZero:int) -> ExpandableBuffer
|
Create an expandable buffer of a certain size, and a position at zero. The buffer can be extended both at head and at tail
|
new(size)
Signature: size:int -> ExpandableBuffer
|
Create an expandable buffer of a certain size, with a default position at zero
|
new()
Signature: unit -> ExpandableBuffer
|
Create an expandable buffer of default size
|
Instance members
Instance member | Description |
ExtendHead(len)
Signature: len:int -> unit
|
Extend the buffer at head by len byte, move the Head pointer.
|
ExtendTail(len)
Signature: len:int -> unit
|
Extend the buffer at tail by len byte, move the Tail pointer.
|
GetBufferAfterTail()
Signature: unit -> byte [] * int * int
|
Get Buffer at tail
|
GetBufferTuple()
Signature: unit -> byte [] * int * int
|
Get Buffer with position and length
Return:
buf: byte[]
start: start position
len: length of the valid buffer
|
GetTruncatedBuffer()
Signature: unit -> byte []
|
Return a buffer (as a new Object)
|
Head()
Signature: unit -> int
|
Head position
|
Head()
Signature: unit -> unit
|
Head position
|
Length
Signature: int
|
Length of the buffer
|
ReadStream(readStream, blocklen)
Signature: (readStream:Stream * blocklen:int) -> unit
|
Read All stream into an expandable buffer
|
Tail()
Signature: unit -> int
|
Tail position
|
Tail()
Signature: unit -> unit
|
Tail position
|
TryExtendHead(len)
Signature: len:int -> unit
|
Extend the buffer at head by len byte
|
TryExtendTail(len)
Signature: len:int -> unit
|
Try extend the buffer at tail by len byte
do not move the tail pointer.
|
Static members
Static member | Description |
DefaultReadStreamBlockLength()
Signature: unit -> int
|
If using Expandable buffer to read stream, the chunk size used to readin stream data
|
DefaultReadStreamBlockLength()
Signature: unit -> unit
|
If using Expandable buffer to read stream, the chunk size used to readin stream data
|
ReadStreamToBuffer(readStream)
Signature: readStream:Stream -> byte [] * int * int
|
Read stream into an expandable buffer
|