ValueCollections 2.1.0
There is a newer version of this package available.
See the version list below for details.
See the version list below for details.
dotnet add package ValueCollections --version 2.1.0
NuGet\Install-Package ValueCollections -Version 2.1.0
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="ValueCollections" Version="2.1.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="ValueCollections" Version="2.1.0" />
<PackageReference Include="ValueCollections" />
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add ValueCollections --version 2.1.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: ValueCollections, 2.1.0"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#addin nuget:?package=ValueCollections&version=2.1.0
#tool nuget:?package=ValueCollections&version=2.1.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
ValueCollections
A set of collections in C# implemented as ref struct
to minimize heap allocations.
ValueList
An implementation of IList<T>
using spans and array pools.
using ValueList<int> numbers = [];
for (int n = 0; n < 100; n++) {
numbers.Add(n);
}
using ValueList<int> evenNumbers = numbers.Where(number => number % 2 == 0);
Console.WriteLine(string.Join(", ", evenNumbers.ToList()));
Benchmarks
Method | Mean | Error | StdDev | Gen0 | Allocated |
---|---|---|---|---|---|
SmallListOfStruct | 17.71 ns | 0.103 ns | 0.091 ns | 0.0255 | 80 B |
SmallValueListOfStruct | 14.50 ns | 0.038 ns | 0.034 ns | - | - |
SmallListOfClass | 25.31 ns | 0.153 ns | 0.135 ns | 0.0306 | 96 B |
SmallValueListOfClass | 17.22 ns | 0.047 ns | 0.044 ns | - | - |
LargeListOfStruct | 20,962.48 ns | 99.370 ns | 92.951 ns | 41.6565 | 131400 B |
LargeValueListOfStruct | 9,663.62 ns | 37.740 ns | 33.455 ns | - | - |
Gotchas
ValueList
should be disposed after use, otherwise the internal rented array will not be returned to the pool.
using ValueList<string> strings = ["a", "b", "c"];
using ValueList<string> whitespaceStrings = strings.Where(string.IsNullOrWhiteSpace);
using ValueList<string> shortWhitespaceStrings = whitespaceStrings.Where(str => str.Length <= 10);
Special Thanks
- linkdotnet/StringBuilder for inspiration.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | 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. net9.0 is compatible. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net8.0
- No dependencies.
-
net9.0
- No dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.