开发者

Is there a no-copy buffer/stream in the C# other than MemoryStream?

开发者 https://www.devze.com 2023-01-14 13:58 出处:网络
Is there a class which, rather than copying data written to it into an internal array which is occasionally resized (as MemoryStream does), retai开发者_高级运维ns a reference to each buffer that users

Is there a class which, rather than copying data written to it into an internal array which is occasionally resized (as MemoryStream does), retai开发者_高级运维ns a reference to each buffer that users pass into it on write, and maintains a data structure which keeps track of each buffer written and the offset/count? It should also support a read mechanism which will provide clients with a buffer, offset, and count (rather than requiring clients to allocate and provide a buffer into which the data is copied for each read).

Essentially I need something which retains data by reference and doesn't do any significant allocations or any data copying behind my back. For some reason I doubt the BCL provides this. Any known implementations?


Would a

List<ArraySegment<byte>>

do?

0

精彩评论

暂无评论...
验证码 换一张
取 消