RentedMemory 1.0.3
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 RentedMemory --version 1.0.3
NuGet\Install-Package RentedMemory -Version 1.0.3
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="RentedMemory" Version="1.0.3" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="RentedMemory" Version="1.0.3" />
<PackageReference Include="RentedMemory" />
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 RentedMemory --version 1.0.3
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: RentedMemory, 1.0.3"
#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.
#:package RentedMemory@1.0.3
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=RentedMemory&version=1.0.3
#tool nuget:?package=RentedMemory&version=1.0.3
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
RentedMemory
RentedMemory is library that builds on ArrayPool to make it explicit that you are using a rented array and adds some functionality.
Includes:
- RentedMemory is a readonly struct wrapper around ArrayPool use it kinda like dispose pattern.
- RentedMemoryBuilder is a StringBuilder alternative with zero allocation (pooled) and works on any struct.
- RentedObjects is a lightweight objectpool where you create the objects yourself.
Getting Started
RentedMemory
// Rent a array of bytes with MinimumSize 24
var Rented = RentedMemory<byte>.Rent(MinimumSize: 24);
//Return it when you dont need it anymore
Rented.Return();
RentedMemoryBuilder
// Rent a array of char with MinimumSize 2
var RentedString = RentedMemoryBuilder<char>.Rent(MinimumSize: 2);
//RentedMemoryBuilder will grow if needed, still using ArrayPool
RentedString.Append("Hello World");
RentedString.Prepend("Hello World");
RentedString.Insert("Hello World");
RentedString.Replace("Hello World", "Hello");
RentedString.Remove("Hello");
//Write to the Span if you want full control, just remember to EnsureSize
RentedString.EnsureSize(FileLength)
int WrittenText = ReadTextFile(RentedString.RemainingSpan);
RentedString.AdvanceRemaining(WrittenText);
//Get the WrittenSpan or WrittenMemory when done and copy it somewhere, then return it
RentedString.WrittenSpan;
RentedString.WrittenMemory;
RentedString.Return();
//Or get the internal RentedMemory out when you are done building and ready to return the builder
RentedString.Return(out RentedMemory<char> RentedArray);
RentedObjects
// Create a new RentedObjects of objects
RentedObjects = new RentedObjects<object>(MaxPooledItemsSize: 16);
//Rents a object or returns null so you can create a new one
//object Object = RentedObjects.Rent() ?? new object();
object? Object = RentedObjects.Rent();
if(Object is null)
Object = new object();
//Return it when you dont need it anymore
RentedObjects.Return(Object);
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net6.0 is compatible. 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 was computed. 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 was computed. 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. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net6.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.