ktsu.Containers
1.1.11
Prefix Reserved
dotnet add package ktsu.Containers --version 1.1.11
NuGet\Install-Package ktsu.Containers -Version 1.1.11
<PackageReference Include="ktsu.Containers" Version="1.1.11" />
<PackageVersion Include="ktsu.Containers" Version="1.1.11" />
<PackageReference Include="ktsu.Containers" />
paket add ktsu.Containers --version 1.1.11
#r "nuget: ktsu.Containers, 1.1.11"
#:package ktsu.Containers@1.1.11
#addin nuget:?package=ktsu.Containers&version=1.1.11
#tool nuget:?package=ktsu.Containers&version=1.1.11
ktsu.Containers
A high-performance collection library for .NET providing specialized container implementations with focus on performance, memory efficiency, and developer experience.
🚀 Features
- OrderedCollection<T>: Maintains elements in sorted order with efficient binary search operations
- OrderedSet<T>: Unique elements maintained in sorted order with full ISet<T> support
- RingBuffer<T>: Fixed-size circular buffer optimized for streaming data scenarios
- Comprehensive Benchmarking: World-class performance validation against .NET collections
📦 Collections
OrderedCollection<T>
A collection that maintains elements in sorted order with efficient insertion and search operations.
Key Features:
- O(log n) insertion maintaining sort order
- O(log n) search operations via binary search
- Multiple constructors with capacity and comparer support
- Implements ICollection<T>, IReadOnlyCollection<T>, IReadOnlyList<T>
Best Use Cases:
- Incremental sorted data building
- Frequent search operations on ordered data
- Scenarios requiring both order and random access
OrderedSet<T>
A set implementation that maintains unique elements in sorted order.
Key Features:
- O(log n) Add/Remove/Contains operations
- Full ISet<T> interface support (Union, Intersection, Except, etc.)
- Sorted enumeration without additional sorting cost
- Memory-efficient list-based implementation
Best Use Cases:
- Unique sorted collections
- Set operations with maintained order
- Mathematical set operations with sorted results
RingBuffer<T>
A fixed-size circular buffer optimized for continuous data streams.
Key Features:
- O(1) insertion and access operations
- Automatic wrapping when capacity is reached
- Index-based access to buffer elements
- Resizing and resampling capabilities
- Power-of-two sizing for optimal performance
Best Use Cases:
- Streaming data processing
- Fixed-size caches
- Sliding window algorithms
- Audio/signal processing buffers
🏆 Performance & Benchmarking
We've implemented a comprehensive benchmarking system using BenchmarkDotNet that validates our implementations against standard .NET collections.
Benchmark Categories
🎯 Container-Specific Benchmarks
- OrderedCollection vs List<T> + Sort vs SortedList<T>
- OrderedSet vs HashSet<T> vs SortedSet<T>
- RingBuffer vs Queue<T> vs List<T> with size limiting
📊 Standard Collection Baselines
Performance baselines for all major .NET collections:
- List<T>, HashSet<T>, SortedSet<T>
- Dictionary<TKey,TValue>, SortedDictionary<TKey,TValue>
- Queue<T>, Stack<T>
- ConcurrentDictionary<TKey,TValue>, ConcurrentQueue<T>
🔄 Cross-Collection Comparisons
Direct comparisons for common scenarios:
- Building ordered collections (incremental vs bulk)
- Set operations across different implementations
- Memory efficiency patterns
- Real-world usage workflows
📈 Performance Analysis
Advanced scenarios including:
- Scalability testing (1K to 100K+ elements)
- Edge cases and worst-case scenarios
- Memory pressure analysis
- Specialized use cases (sliding windows, priority queues)
Running Benchmarks
Quick Start
# Fast development feedback
.\scripts\run-benchmarks.ps1 -Target Quick
# Compare specific containers
.\scripts\run-benchmarks.ps1 -Target OrderedSet -Export Html
# Cross-collection analysis
.\scripts\run-benchmarks.ps1 -Target CrossComparison -Export All
# Full benchmark suite
.\scripts\run-benchmarks.ps1 -Target All -Export Html
Available Targets
| Target | Description |
|---|---|
Quick |
Fast subset for development feedback |
OrderedCollection |
OrderedCollection<T> vs alternatives |
OrderedSet |
OrderedSet<T> vs alternatives |
RingBuffer |
RingBuffer<T> vs alternatives |
Standard |
Built-in .NET collection baselines |
CrossComparison |
Direct cross-collection comparisons |
PerformanceAnalysis |
Scalability and edge case analysis |
All |
Complete benchmark suite |
Command Line Options
# Manual benchmark execution
dotnet run --project Containers.Benchmarks --configuration Release
# Filtered benchmarks
dotnet run --project Containers.Benchmarks --configuration Release -- --filter "*Add*"
# Export results
dotnet run --project Containers.Benchmarks --configuration Release -- --exporters html,csv,json
📋 Installation
<PackageReference Include="ktsu.Containers" Version="1.0.0" />
🔧 Usage Examples
OrderedCollection<T>
// Create and populate
var collection = new OrderedCollection<int>();
collection.Add(3);
collection.Add(1);
collection.Add(2);
// Collection automatically maintains order: [1, 2, 3]
// Efficient search
bool contains = collection.Contains(2); // O(log n) binary search
// Access by index
int first = collection[0]; // 1
OrderedSet<T>
// Create with initial data
var set = new OrderedSet<int> { 3, 1, 4, 1, 5 };
// Set contains unique elements in order: [1, 3, 4, 5]
// Set operations
var other = new OrderedSet<int> { 4, 5, 6 };
set.UnionWith(other); // [1, 3, 4, 5, 6]
RingBuffer<T>
// Create fixed-size buffer
var buffer = new RingBuffer<int>(3);
buffer.PushBack(1);
buffer.PushBack(2);
buffer.PushBack(3);
buffer.PushBack(4); // Overwrites first element
// Buffer contains: [2, 3, 4]
// Index access
int latest = buffer[buffer.Count - 1]; // 4 (most recent)
🛠️ Development
Building
dotnet build
Testing
dotnet test
Benchmarking
# Quick performance check
.\scripts\run-benchmarks.ps1 -Target Quick
# Comprehensive analysis
.\scripts\run-benchmarks.ps1 -Target All -Export Html
📊 Performance Characteristics
OrderedCollection<T>
- ✅ Excellent for: Incremental sorted insertions, frequent searches
- ⚠️ Consider alternatives for: Large bulk operations (List<T> + Sort may be faster)
- 🎯 Sweet spot: 100-10,000 elements with mixed insert/search operations
OrderedSet<T>
- ✅ Excellent for: Unique sorted collections, set operations with order
- ⚠️ Consider alternatives for: Pure membership testing (HashSet<T> is faster)
- 🎯 Sweet spot: Mathematical set operations requiring sorted results
RingBuffer<T>
- ✅ Excellent for: Streaming data, fixed-size caches, sliding windows
- ⚠️ Consider alternatives for: Dynamic growth requirements
- 🎯 Sweet spot: Continuous data streams with occasional random access
🤝 Contributing
- Fork the repository
- Create a feature branch
- Make your changes
- Add comprehensive tests
- Run benchmarks to validate performance
- Submit a pull request
Adding New Containers
When adding new containers:
- Implement the container in
Containers/ - Add comprehensive tests in
Containers.Test/ - Create benchmark comparisons in
Containers.Benchmarks/ - Update documentation
📝 License
Licensed under the MIT License. See LICENSE.md for details.
🏗️ Architecture
The library is built with performance and reliability in mind:
- Zero-allocation operations where possible
- Power-of-two sizing for optimal memory access patterns
- Binary search algorithms for O(log n) performance
- Comprehensive test coverage ensuring reliability
- Benchmark-driven development validating performance claims
🎯 Design Principles
- Performance First: Every operation is optimized for speed and memory efficiency
- Standard Compliance: Full compatibility with .NET collection interfaces
- Predictable Behavior: Clear performance characteristics and edge case handling
- Developer Experience: Intuitive APIs with comprehensive documentation
- Validation: Extensive testing and benchmarking ensures reliability
This library provides high-performance alternatives to standard .NET collections while maintaining familiar APIs and adding specialized functionality for common use cases.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 is compatible. net5.0-windows was computed. 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 is compatible. 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 is compatible. 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 was computed. 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. |
-
.NETStandard 2.0
- System.Memory (>= 4.6.3)
- System.Threading.Tasks.Extensions (>= 4.6.3)
-
.NETStandard 2.1
- No dependencies.
-
net10.0
- No dependencies.
-
net5.0
- No dependencies.
-
net6.0
- No dependencies.
-
net7.0
- No dependencies.
-
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.
| Version | Downloads | Last Updated |
|---|---|---|
| 1.1.11 | 28 | 8/18/2026 |
| 1.1.10 | 86 | 8/17/2026 |
| 1.1.9 | 86 | 8/14/2026 |
| 1.1.8 | 87 | 8/11/2026 |
| 1.1.7 | 155 | 7/1/2026 |
| 1.1.6 | 122 | 6/30/2026 |
| 1.1.5 | 128 | 6/29/2026 |
| 1.1.4 | 122 | 6/28/2026 |
| 1.1.3 | 128 | 6/28/2026 |
| 1.1.2 | 162 | 6/12/2026 |
| 1.1.1 | 137 | 6/12/2026 |
| 1.1.0 | 143 | 6/12/2026 |
| 1.0.13-pre.1 | 95 | 2/17/2026 |
| 1.0.12 | 874 | 2/16/2026 |
| 1.0.12-pre.1 | 81 | 2/16/2026 |
| 1.0.11 | 141 | 2/14/2026 |
| 1.0.10 | 137 | 2/14/2026 |
| 1.0.10-pre.7 | 84 | 2/6/2026 |
| 1.0.10-pre.6 | 87 | 2/5/2026 |
| 1.0.10-pre.5 | 91 | 2/3/2026 |
## v1.1.11 (patch)
Changes since v1.1.10:
- Stop Update SDKs failing when there is nothing to update ([@matt-edmondson](https://github.com/matt-edmondson))