JUtility.JObjectPool 1.0.0

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

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

J Object Pool

This is the Object Pool data structure created with a double linked list.

How does it work?

The logic behind the J Object Pool is that the head node always shows the next available node while the tail node always shows the last reserved node that is still in use. When a node is needed, the pool returns the head node and put the node at the end of the list, which the node becomes the new tail node. If the head node is not avaialable to use, the pool's size is increased first and then it returns an available node.

How to use?

The data structure is under the JUtility.JObjectPool namespace.

using JUtility.JObjectPool;

JObjectPool<MyClass> pool = new JObjectPool<MyClass>(50, 10);   // The initial size of the pool is 50 and it will increase by 10 each time there is no available node in the pool.

// Get the next available node by simply calling the GetNode method.
JObjectPoolNode<MyClass> node = pool.GetNode();

// If the data inside of the node is a nullable type, the Data property must be checked if it is null for first use.
if (node.Data == null)
    node.Data = new MyClass();
node.Data...   // Use the properties/values/methods inside of the Data property.

// When the node is not needed anymore, it must be returned to the pool.

Big O Notations

JObjectPool | Function Name | Notation | | ---------------------- | ---------| | Constructor | O(n) | | IncreasePoolSize | O(n) | | GetNode | O(1) | | GetAllNodes | O(n) | | ReturnNode | O(1) | | RemoveNode | O(1) | | ClearPool | O(n) |

JObjectPoolNode | Function Name | Notation | | ---------------- | ---------| | Constructor | O(1) | | OnRemove | O(1) | | ReturnToPool | O(1) |


This project is licensed under the MIT License - see the LICENSE.md file for details.

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

Version Downloads Last updated
1.0.0 238 7/10/2022