Thetype exposes the following members.
Constructs an empty list.
Constructs a block array from a buffer.
Constructs an array with the specified capacity.
Constructs an array from the blocks passed.
Constructs an array with the specified capacity and block size.
|BlockArray(Int32, Int32, Int32)|
Constructs an array with the specified capacity, block size, and block offset.
The default offset to use when adding new blocks to the array.
The size of new blocks added when extending the array.
Returns the number of blocks in the list.
Accesses the indexed byte in the logical array formed by concatentating all of the blocks.
Returns the total size of all the blocks in bytes.
Appends a block formed by a buffer to the array.
Appends a block to end of the array.
Appends all blocks from a block array to this array.
|Append(BlockArray, Int32, Int32)|
Appends blocks from a block array to this array.
Returns a shallow copy of the block array.
Copies bytes from the byte array passed into the blocks.
Copies bytes from the logical offset in the blocks to the target byte array.
Determines whether the specified object is equal to the current object.(Inherited from Object.)
Adds blocks to the array as necessary to ensure that the total size of these blocks is at least equal to the value passed.
Extracts a range of bytes from the array from the specified index to the end of the array into newly created block array.
Extracts a range of bytes from the array into newly created block array.
Returns the indexed block in the list.
Returns an array to the underlying blocks.
Serves as the default hash function.(Inherited from Object.)
Gets the Type of the current instance.(Inherited from Object.)
Reloads cached information about the blocks in the array.
Used internally by unit tests to reset any internal positional optimization information maintained by the class.
Adjusts the blocks in the array such that their sizes total exactly to the value passed.
Assembles the blocks referenced by the array into a contiguous byte array.
Returns a string that represents the current object.(Inherited from Object.)
Removes blocks from the and of the array array such that only those blocks necessary to achieve the specified capacity remain.
The purpose of MemoryStream class. Rather than doing I/O to a single large buffer, the provides the underlying functionality for spreading I/O across multiple blocks. This avoids any need to reallocate and copy a large buffer as the stream grows an also tends to allocate consistently sized memory blocks, making life easier for the memory allocator.is to avoid performance robbing buffer reallocations and copies and large obvject heap applications as can happen with extensive use of the
This class is pretty flexible. Blocks can be explicitly added and removed from the class or the ExtendTo(Int32), TruncateTo(Int32), or SetExactSize(Int32) methods can be used have the class handle block management.
The BlockSize and BlockOffset properties are used by the internal block management methods when allocating new blocks. BlockSize defaults to 512 and specifies the size of new blocks. BlockOffset defaults to 0. New blocks will have their Offset field set to BlockOffset.
BlockOffset provides for some tricky performance optimizations. A common situation in network protocols is the need to fragment serialized data across multiple data packets with fixed sized headers. Setting BlockOffset to the size of the fixed header will reserve these bytes at the beginning of each block. The data can be serialized into the array and then afterwards, the headers can be written manually into each block. This technique can avoid lots of buffer copying.