IO.Github.Hcoona.Collections.CircularList 1.0.2

dotnet add package IO.Github.Hcoona.Collections.CircularList --version 1.0.2
                    
NuGet\Install-Package IO.Github.Hcoona.Collections.CircularList -Version 1.0.2
                    
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="IO.Github.Hcoona.Collections.CircularList" Version="1.0.2" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="IO.Github.Hcoona.Collections.CircularList" Version="1.0.2" />
                    
Directory.Packages.props
<PackageReference Include="IO.Github.Hcoona.Collections.CircularList" />
                    
Project file
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 IO.Github.Hcoona.Collections.CircularList --version 1.0.2
                    
#r "nuget: IO.Github.Hcoona.Collections.CircularList, 1.0.2"
                    
#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 IO.Github.Hcoona.Collections.CircularList@1.0.2
                    
#: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=IO.Github.Hcoona.Collections.CircularList&version=1.0.2
                    
Install as a Cake Addin
#tool nuget:?package=IO.Github.Hcoona.Collections.CircularList&version=1.0.2
                    
Install as a Cake Tool

CircularList

A high-performance, generic circular buffer (circular list) library for .NET, supporting multiple target frameworks. Compatible with .NET Framework 4.6.1+, .NET Core 2.0+, .NET 6/8/9+, and modern .NET platforms.

Features

  • Fixed capacity, automatically overwrites the oldest element on overflow
  • Generic, fully implements IList<T> API
  • Multi-targeting: netstandard2.0, netstandard2.1, net462, net8.0, net9.0
  • Span<T>/Memory<T> support on modern platforms
  • Overflow event notification when an element is overwritten
  • Not thread-safe (add your own locking for concurrency)

Installation

Install from NuGet (assuming package name is CircularList):

# .NET CLI
dotnet add package CircularList

Quick Start

using IO.Github.Hcoona.Collections;

var list = new CircularList<int>(capacity: 3);
list.Add(1);
list.Add(2);
list.Add(3);
list.Add(4); // Now 1 is overwritten, list contains [2,3,4]

foreach (var item in list)
{
    Console.WriteLine(item); // Outputs 2, 3, 4
}

// Subscribe to overflow event
list.OnOverflow += (sender, overwritten) =>
{
    Console.WriteLine($"Overwritten: {overwritten}");
};

Main API

  • CircularList<T>(int capacity): Create a circular list with the specified capacity
  • void Add(T item): Add an element, overwriting the oldest if full
  • T this[int index]: Indexer, 0 is the oldest element
  • int Capacity: The fixed capacity
  • int Count: Current number of elements
  • event EventHandler<T> OnOverflow: Raised when an element is overwritten
  • ReadOnlySpan<T> AsSpan(): Efficient access to the circular list contents
  • bool Contains(T item): Check if the list contains a specific item
  • int IndexOf(T item): Find the logical index of a specific item
  • void Clear(): Remove all items from the list
  • void CopyTo(T[] array, int arrayIndex): Copy all items to an array

Multi-target Framework Support

Target Framework Compatible Platforms Modern Features
netstandard2.0 .NET Framework 4.6.1+ Basic functionality
netstandard2.1 .NET Core 3.0+/Mono Span<T> support
net462 .NET Framework 4.6.2+ Basic functionality
net8.0 .NET 8 All features
net9.0 .NET 9 All features

Note: On netstandard2.0, System.Memory is referenced automatically to provide Span<T> compatible APIs.

Performance & Use Cases

  • Ideal for logs, caches, sliding windows, and any fixed-capacity, cyclic-overwrite scenario
  • Backed by an array, O(1) for indexing and adding
  • Remove/RemoveAt/Insert operations are not supported (throw NotSupportedException)
  • CopyTo/IndexOf/Contains are fully supported for read operations

License

GPL-3.0-or-later


Feedback and contributions are welcome! Open an issue or PR.

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 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.  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. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 is compatible. 
.NET Framework net461 was computed.  net462 is compatible.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  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.

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.2 114 7/15/2025

# Release Notes
## Version 1.0.2 (Initial Release)
### Features
- High-performance circular list implementation
- Multi-framework support (.NET Standard 2.0/2.1, .NET Framework 4.6.2, .NET 8.0/9.0)
- O(1) insertion and removal operations
- Efficient buffer management for queue operations
- Support for cyclic data structures
- Comprehensive API documentation
### Performance
- Optimized for high-throughput scenarios
- Memory-efficient implementation
- Support for `Span<T>` and `Memory<T>` on modern platforms
### Compatibility
- Full compatibility with .NET Standard 2.0+ and .NET Framework 4.6.2+
- Tested on multiple target frameworks