SimEi.PooledLinkedList 1.0.0

dotnet add package SimEi.PooledLinkedList --version 1.0.0
NuGet\Install-Package SimEi.PooledLinkedList -Version 1.0.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="SimEi.PooledLinkedList" Version="1.0.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add SimEi.PooledLinkedList --version 1.0.0
#r "nuget: SimEi.PooledLinkedList, 1.0.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.
// Install SimEi.PooledLinkedList as a Cake Addin
#addin nuget:?package=SimEi.PooledLinkedList&version=1.0.0

// Install SimEi.PooledLinkedList as a Cake Tool
#tool nuget:?package=SimEi.PooledLinkedList&version=1.0.0

PooledLinkedList

Implementation of a collection similar to the standard System.Collections.Generic.LinkedList<T>, but without heap allocation on every item insertion by using struct pool under the hood.

Motivation

When working with Unity, sometimes I had to use the standard LinkedList<T>, but it came with a big cost - as the Unity's garbage collector is a technology way behind current GC for CoreCLR (as for August 2023 - this is going to change soon because Unity is working on moving to CoreCLR), you have to be careful with every heap allocation. This way, I came up with an idea of implementing LinkedList<T> with a node pool, being an array of structs, so allocations are needed only during expanding the pool.

Target Frameworks

  • netstandard2.1

Getting started

Install through NuGet package manager.

Tests in SimEi.PooledLinkedList.Tests package use MSTest.

Usage

API is similar to the standard LinkedList<T>.

Creating list

using SimEi.Collections;
var list1 = new PooledLinkedList<int>();
var list2 = new PooledLinkedList<int>(capacity: 5); // Initial pool capacity = 5.

Item manipulation

list.AddFirst(1);
var last = list.AddLast(3);
var newLast = list.AddAfter(last, 4);
var second = list.AddBefore(last, 2);
// list contains { 1, 2, 3, 4 }.

list.Remove(last);
// list contains { 1, 2, 4 }.

newLast.Value = 100;
// list contains { 1, 2, 100 }.

list.Clear()
// list is empty.

Item manipulation through ItemHandle

You can also add items relative to the current node handle.

list.AddFirst(5).AddAfter(10).AddAfter(20).AddBefore(15);
// list contains { 5, 10, 15, 20 }.

License

This project is licensed under MIT license.

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  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 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. 
.NET Core netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • .NETStandard 2.1

    • 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.

Version Downloads Last updated
1.0.0 142 8/17/2023