FixedSizeBuffers 0.4.3
dotnet add package FixedSizeBuffers --version 0.4.3
NuGet\Install-Package FixedSizeBuffers -Version 0.4.3
<PackageReference Include="FixedSizeBuffers" Version="0.4.3" />
paket add FixedSizeBuffers --version 0.4.3
#r "nuget: FixedSizeBuffers, 0.4.3"
// Install FixedSizeBuffers as a Cake Addin #addin nuget:?package=FixedSizeBuffers&version=0.4.3 // Install FixedSizeBuffers as a Cake Tool #tool nuget:?package=FixedSizeBuffers&version=0.4.3
FixedSizeBuffers
A collection of fixed-size structs which can be treated as Span
s. A replacement for stackalloc
(or fixed
-size buffers), but these buffers can contain reference types (and can't be dynamically sized).
void Copy(TextReader reader, TextWriter writer)
{
// Allocate 2kB on the stack
var buffer = new FixedSizeBuffer1024<char>();
var span = buffer.AsSpan();
var count = -1;
while (count != 0)
{
count = reader.Read(span);
writer.Write(span.Slice(count));
}
buffer.Dispose();
}
Buffers are provided in powers-of-two lengths, from 2 to 8192.
I hope you know what you're doing
Use of this library is potentially unsafe. When calling AsSpan
or AsReadOnlySpan
, you must make sure the Span
doesn't outlive the FixedSizeBuffer
. Basically, don't return the Span
.
Span<int> Bad()
{
var buffer = new FixedSizeBuffer4<int>();
return buffer.AsSpan(); // Don't do this
}
You can safely pass around spans into buffers which live on the heap — but if you're doing that you might as well use an array.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 is compatible. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
.NET Core | netcoreapp3.0 was computed. netcoreapp3.1 is compatible. |
.NET Standard | netstandard2.1 is compatible. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETCoreApp 3.1
- System.Runtime.CompilerServices.Unsafe (>= 4.7.1)
-
.NETStandard 2.1
- System.Runtime.CompilerServices.Unsafe (>= 4.7.1)
-
net5.0
- System.Runtime.CompilerServices.Unsafe (>= 4.7.1)
-
net8.0
- System.Runtime.CompilerServices.Unsafe (>= 4.7.1)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on FixedSizeBuffers:
Package | Downloads |
---|---|
Sawmill
Simple tools for working with immutable trees, developed at Stack Overflow |
GitHub repositories
This package is not used by any popular GitHub repositories.