Ecng.Collections 1.0.284

There is a newer version of this package available.
See the version list below for details.
dotnet add package Ecng.Collections --version 1.0.284
                    
NuGet\Install-Package Ecng.Collections -Version 1.0.284
                    
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="Ecng.Collections" Version="1.0.284" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Ecng.Collections" Version="1.0.284" />
                    
Directory.Packages.props
<PackageReference Include="Ecng.Collections" />
                    
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 Ecng.Collections --version 1.0.284
                    
#r "nuget: Ecng.Collections, 1.0.284"
                    
#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 Ecng.Collections@1.0.284
                    
#: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=Ecng.Collections&version=1.0.284
                    
Install as a Cake Addin
#tool nuget:?package=Ecng.Collections&version=1.0.284
                    
Install as a Cake Tool

Ecng.Collections

Thread-safe collections, specialized data structures, and collection utilities for high-performance scenarios.

Thread-Safe Collections

All synchronized collections provide thread-safe operations with internal locking.

SynchronizedDictionary

Thread-safe wrapper around Dictionary<TKey, TValue>.

var dict = new SynchronizedDictionary<int, string>();

// Thread-safe operations
dict[1] = "one";
dict.Add(2, "two");

if (dict.TryGetValue(1, out var value))
    Console.WriteLine(value); // "one"

// Manual locking for compound operations
using (dict.EnterScope())
{
    if (!dict.ContainsKey(3))
        dict.Add(3, "three");
}

SynchronizedList

Thread-safe list with notification support.

var list = new SynchronizedList<string>();

list.Add("item1");
list.AddRange(new[] { "item2", "item3" });

// Safe iteration with scope
using (list.EnterScope())
{
    foreach (var item in list)
        Console.WriteLine(item);
}

CachedSynchronizedList

Thread-safe list that caches its array representation for fast enumeration.

var list = new CachedSynchronizedList<int>();

list.Add(1);
list.Add(2);
list.Add(3);

// Cache is computed once and reused until list changes
int[] cached = list.Cache;
foreach (var item in cached)
    Console.WriteLine(item);

// After modification, cache is invalidated
list.Add(4);
int[] newCache = list.Cache; // Recomputed

CachedSynchronizedDictionary

Thread-safe dictionary with cached key/value arrays.

var dict = new CachedSynchronizedDictionary<string, int>();

dict["a"] = 1;
dict["b"] = 2;

// Cached arrays for fast iteration
string[] keys = dict.CachedKeys;
int[] values = dict.CachedValues;
KeyValuePair<string, int>[] pairs = dict.CachedPairs;

SynchronizedSet

Thread-safe HashSet<T> wrapper.

var set = new SynchronizedSet<int>();

set.Add(1);
set.Add(2);
bool added = set.Add(1); // false, already exists

bool contains = set.Contains(1); // true

Specialized Collections

PairSet - Bidirectional Dictionary

Allows lookup by both key and value.

var pairs = new PairSet<int, string>();

pairs.Add(1, "one");
pairs.Add(2, "two");

// Forward lookup (key -> value)
string value = pairs.GetValue(1); // "one"

// Reverse lookup (value -> key)
int key = pairs.GetKey("two"); // 2

// Check existence
bool hasKey = pairs.ContainsKey(1);
bool hasValue = pairs.ContainsValue("one");

// Remove by value
pairs.RemoveByValue("one");

SynchronizedPairSet

Thread-safe version of PairSet.

var pairs = new SynchronizedPairSet<Guid, string>();

var id = Guid.NewGuid();
pairs.Add(id, "session-1");

// Thread-safe bidirectional lookup
if (pairs.TryGetValue(id, out var session))
    Console.WriteLine(session);

if (pairs.TryGetKey("session-1", out var foundId))
    Console.WriteLine(foundId);

CircularBuffer

Fixed-size buffer that overwrites oldest elements when full.

var buffer = new CircularBuffer<int>(capacity: 3);

buffer.PushBack(1);
buffer.PushBack(2);
buffer.PushBack(3);
// Buffer: [1, 2, 3]

buffer.PushBack(4);
// Buffer: [2, 3, 4] - oldest (1) was overwritten

int front = buffer.Front(); // 2
int back = buffer.Back();   // 4
int second = buffer[1];     // 3

// Remove from ends
buffer.PopFront(); // Removes 2
buffer.PopBack();  // Removes 4

// Convert to array
int[] arr = buffer.ToArray();

// Resize buffer
buffer.Capacity = 5; // Grow
buffer.Capacity = 2; // Shrink (keeps newest elements)

CircularBufferEx

Extended circular buffer with additional operations.

var buffer = new CircularBufferEx<decimal>(100);

// Add elements
buffer.PushBack(1.5m);
buffer.PushBack(2.5m);

// Sum, min, max operations
decimal sum = buffer.Sum;
decimal min = buffer.Min;
decimal max = buffer.Max;

NumericCircularBufferEx

Circular buffer optimized for numeric calculations with running statistics.

var buffer = new NumericCircularBufferEx<double>(100);

for (int i = 0; i < 100; i++)
    buffer.PushBack(Math.Sin(i));

// Efficient statistics (computed incrementally)
double sum = buffer.Sum;
double min = buffer.Min;
double max = buffer.Max;

Queue and Stack Extensions

SynchronizedQueue

Thread-safe queue.

var queue = new SynchronizedQueue<Message>();

queue.Enqueue(new Message("hello"));

if (queue.TryDequeue(out var msg))
    Process(msg);

SynchronizedStack

Thread-safe stack.

var stack = new SynchronizedStack<int>();

stack.Push(1);
stack.Push(2);

if (stack.TryPop(out var value))
    Console.WriteLine(value); // 2

QueueEx / StackEx

Extended queue and stack with additional peek operations.

var queue = new QueueEx<int>();
queue.Enqueue(1);
queue.Enqueue(2);
queue.Enqueue(3);

int first = queue.PeekFirst();  // 1 (front)
int last = queue.PeekLast();    // 3 (back)

Ordered Channels

BaseOrderedChannel

Base class for ordered message processing with channels.

// Used for ordered async message processing
// See ChannelExtensions for usage patterns

Bit Array Operations

BitArrayWriter / BitArrayReader

Efficient bit-level I/O for binary data.

// Writing bits
var writer = new BitArrayWriter();
writer.Write(true);           // 1 bit
writer.Write(42, 8);          // 8 bits
writer.WriteInt(1000);        // Variable-length int

byte[] data = writer.ToArray();

// Reading bits
var reader = new BitArrayReader(data);
bool flag = reader.Read();     // 1 bit
int value = reader.Read(8);    // 8 bits
int number = reader.ReadInt(); // Variable-length int

Collection Interfaces

INotifyList

List that raises events on modifications.

public interface INotifyList<T> : IList<T>
{
    event Action<T> Adding;
    event Action<T> Added;
    event Action<T> Removing;
    event Action<T> Removed;
    event Action Clearing;
    event Action Cleared;
    event Action Changed;
}

ISynchronizedCollection

Interface for thread-safe collections.

public interface ISynchronizedCollection<T> : ICollection<T>
{
    Lock SyncRoot { get; }
    LockScope EnterScope();
}

Extension Methods

using Ecng.Collections;

// Check if collection is empty
IEnumerable<int> items = GetItems();
if (items.IsEmpty())
    return;

// Safe first/last
var first = items.FirstOr(defaultValue: -1);
var last = items.LastOr(defaultValue: -1);

// Batch processing
foreach (var batch in items.Batch(100))
    ProcessBatch(batch);

// Index lookup
int index = items.IndexOf(x => x > 10);

NuGet

Install-Package Ecng.Collections
Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  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 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 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 was computed. 
.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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (8)

Showing the top 5 NuGet packages that depend on Ecng.Collections:

Package Downloads
Ecng.Reflection

Ecng system framework

Ecng.Security

Ecng system framework

Ecng.StringSearch

Ecng system framework

Ecng.Roslyn

Ecng system framework

Ecng.Backup.Mega

Ecng system framework

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.285 337 2/4/2026
1.0.284 1,627 2/1/2026
1.0.283 1,676 1/26/2026
1.0.282 866 1/22/2026
1.0.281 2,111 1/19/2026
1.0.280 838 1/19/2026
1.0.279 815 1/18/2026
1.0.278 807 1/18/2026
1.0.277 1,453 1/14/2026
1.0.276 870 1/13/2026
1.0.275 821 1/13/2026
1.0.274 1,252 1/9/2026
1.0.273 1,375 1/9/2026
1.0.272 20,710 1/4/2026
1.0.271 37,780 12/30/2025
1.0.270 40,340 12/29/2025
1.0.269 58,825 12/26/2025
1.0.268 58,835 12/26/2025
1.0.267 58,879 12/26/2025
1.0.266 58,886 12/26/2025
1.0.265 64,374 12/25/2025
1.0.264 65,641 12/25/2025
1.0.263 82,344 12/22/2025
1.0.262 89,354 12/21/2025
1.0.261 97,659 12/19/2025
1.0.260 98,330 12/19/2025
1.0.259 106,709 12/17/2025
1.0.258 121,291 12/15/2025
1.0.257 121,196 12/15/2025
1.0.256 127,458 12/14/2025
1.0.255 148,274 12/12/2025
1.0.254 147,586 12/12/2025
1.0.253 147,212 12/12/2025
1.0.252 147,207 12/12/2025
1.0.251 147,957 12/12/2025
1.0.250 211,099 12/2/2025
1.0.249 211,321 12/2/2025
1.0.248 212,100 12/2/2025
1.0.247 227,668 11/30/2025
1.0.246 230,671 11/29/2025
1.0.245 232,834 11/28/2025
1.0.244 233,544 11/28/2025
1.0.243 237,354 11/27/2025
1.0.242 257,102 11/24/2025
1.0.241 258,842 11/24/2025
1.0.240 263,621 11/23/2025
1.0.239 269,034 11/22/2025
1.0.238 287,148 11/20/2025
1.0.237 310,122 11/18/2025
1.0.236 310,802 11/18/2025
1.0.235 353,553 11/13/2025
1.0.234 386,209 11/10/2025
1.0.233 426,860 11/1/2025
1.0.232 426,112 10/28/2025
1.0.231 426,077 10/27/2025
1.0.230 425,942 10/27/2025
1.0.229 425,872 10/25/2025
1.0.228 476,339 10/3/2025
1.0.227 476,404 9/28/2025
1.0.226 476,149 9/25/2025
1.0.225 500,494 8/30/2025
1.0.224 474,743 7/13/2025
1.0.223 466,142 7/13/2025
1.0.222 466,160 7/12/2025
1.0.221 467,501 7/8/2025
1.0.220 466,954 7/4/2025
1.0.219 466,236 7/2/2025
1.0.218 471,121 6/16/2025
1.0.217 466,392 6/9/2025
1.0.216 466,253 6/8/2025
1.0.215 467,899 5/21/2025
1.0.214 466,376 5/17/2025
1.0.213 467,963 5/12/2025
1.0.212 466,288 5/12/2025
1.0.211 468,788 4/17/2025
1.0.210 471,385 3/22/2025
1.0.209 466,263 3/20/2025
1.0.208 466,194 3/20/2025
1.0.207 466,232 3/19/2025
1.0.206 471,426 2/26/2025
1.0.205 466,322 2/26/2025
1.0.204 474,745 2/5/2025
1.0.203 470,245 1/21/2025
1.0.202 469,609 1/14/2025
1.0.201 468,433 1/12/2025
1.0.200 466,887 1/10/2025
1.0.199 470,571 12/27/2024
1.0.198 467,337 11/20/2024
1.0.197 469,841 11/18/2024
1.0.196 468,151 11/7/2024
1.0.195 467,552 10/19/2024
1.0.194 469,393 10/12/2024
1.0.193 469,948 10/5/2024
1.0.192 471,059 9/18/2024
1.0.191 466,342 9/17/2024
1.0.190 470,752 9/3/2024
1.0.189 466,407 9/1/2024
1.0.188 480,507 6/12/2024
1.0.187 469,263 5/28/2024
1.0.186 470,011 5/4/2024
1.0.185 468,687 4/23/2024
1.0.184 467,770 4/21/2024
1.0.183 466,596 4/14/2024
1.0.182 471,955 3/28/2024
1.0.181 466,540 3/17/2024
1.0.180 469,966 2/23/2024
1.0.179 466,560 2/23/2024
1.0.178 469,932 2/18/2024
1.0.177 466,551 2/18/2024
1.0.176 466,612 2/16/2024
1.0.175 468,693 2/13/2024
1.0.174 468,417 2/8/2024
1.0.173 468,875 2/5/2024
1.0.172 466,577 2/4/2024
1.0.171 469,132 1/23/2024
1.0.170 466,709 1/23/2024
1.0.169 468,403 1/12/2024
1.0.168 471,843 1/2/2024
1.0.167 466,931 12/29/2023
1.0.166 485,111 11/12/2023
1.0.165 878,223 11/10/2023
1.0.164 466,881 11/10/2023
1.0.163 877,919 11/9/2023
1.0.162 878,823 11/3/2023
1.0.161 877,752 11/1/2023
1.0.160 877,796 11/1/2023
1.0.159 903,159 9/8/2023
1.0.158 878,218 9/8/2023
1.0.157 878,476 9/3/2023
1.0.156 878,730 8/21/2023
1.0.155 468,139 8/14/2023
1.0.154 879,251 8/10/2023
1.0.153 918,912 6/29/2023
1.0.152 893,324 5/27/2023
1.0.151 467,826 5/21/2023
1.0.150 467,931 5/19/2023
1.0.149 904,318 5/8/2023
1.0.148 884,226 4/21/2023
1.0.147 929,948 4/3/2023
1.0.146 886,393 3/13/2023
1.0.145 898,243 3/6/2023
1.0.144 880,376 2/26/2023
1.0.143 484,310 2/21/2023
1.0.142 468,724 2/20/2023
1.0.141 469,980 2/15/2023
1.0.140 468,747 2/14/2023
1.0.139 912,205 2/9/2023
1.0.138 485,163 2/7/2023
1.0.137 880,255 2/4/2023
1.0.136 900,321 2/2/2023
1.0.135 896,605 1/30/2023
1.0.134 474,767 1/18/2023
1.0.133 923,987 12/30/2022
1.0.132 882,309 12/23/2022
1.0.131 900,721 12/12/2022
1.0.130 903,360 12/4/2022
1.0.129 880,819 12/4/2022
1.0.128 881,548 11/30/2022
1.0.127 469,941 11/29/2022
1.0.126 470,105 11/28/2022
1.0.125 885,037 11/18/2022
1.0.124 908,301 11/11/2022
1.0.123 881,088 11/11/2022
1.0.122 470,174 11/10/2022
1.0.121 881,362 11/5/2022
1.0.120 882,708 11/4/2022
1.0.119 904,812 11/1/2022
1.0.118 905,098 10/16/2022
1.0.117 888,344 9/10/2022
1.0.116 931,922 9/8/2022
1.0.115 881,615 9/8/2022
1.0.114 470,799 9/8/2022
1.0.113 883,947 9/4/2022
1.0.112 560,393 8/24/2022
1.0.111 891,015 8/8/2022
1.0.110 884,689 7/26/2022
1.0.109 881,837 7/26/2022
1.0.108 934,302 7/19/2022
1.0.107 515,845 7/18/2022
1.0.106 475,921 7/8/2022
1.0.105 886,042 6/18/2022
1.0.104 881,857 6/6/2022
1.0.103 978,418 4/30/2022
1.0.102 882,110 4/20/2022
1.0.101 882,161 4/10/2022
1.0.100 882,149 4/7/2022
1.0.99 882,065 4/7/2022
1.0.98 882,250 4/2/2022
1.0.97 482,640 3/29/2022
1.0.96 474,206 3/27/2022
1.0.95 757,441 1/24/2022
1.0.94 1,041,105 12/29/2021
1.0.93 908,369 12/20/2021
1.0.92 881,789 12/13/2021
1.0.91 937,900 12/6/2021
1.0.90 472,423 12/2/2021
1.0.89 909,488 11/29/2021
1.0.88 908,081 11/22/2021
1.0.87 469,235 11/17/2021
1.0.86 909,934 11/13/2021
1.0.85 472,680 11/10/2021
1.0.84 880,253 11/9/2021
1.0.83 531,807 11/5/2021
1.0.82 881,992 11/4/2021
1.0.81 880,129 11/4/2021
1.0.80 880,065 11/3/2021
1.0.79 880,293 10/30/2021
1.0.78 911,551 10/21/2021
1.0.77 880,729 10/17/2021
1.0.76 941,489 10/14/2021
1.0.75 891,361 10/13/2021
1.0.74 880,323 10/12/2021
1.0.73 911,965 10/11/2021
1.0.72 880,151 10/9/2021
1.0.71 915,340 10/7/2021
1.0.70 917,389 10/7/2021
1.0.69 880,266 10/7/2021
1.0.68 469,406 10/6/2021
1.0.67 880,389 9/28/2021
1.0.66 914,129 9/23/2021
1.0.65 882,022 9/10/2021
1.0.64 880,136 9/9/2021
1.0.63 880,154 9/8/2021
1.0.62 880,276 9/8/2021
1.0.61 911,037 9/6/2021
1.0.60 469,616 8/31/2021
1.0.59 469,387 8/30/2021
1.0.58 913,325 7/31/2021
1.0.57 939,839 7/30/2021
1.0.56 880,600 7/26/2021
1.0.55 969,183 7/5/2021
1.0.54 469,616 7/1/2021
1.0.53 942,713 6/4/2021
1.0.52 970,392 4/26/2021
1.0.51 910,984 4/19/2021
1.0.50 1,028,990 4/7/2021
1.0.49 910,197 4/3/2021
1.0.48 1,058,216 3/22/2021
1.0.47 992,048 3/4/2021
1.0.46 913,373 2/26/2021
1.0.45 1,047,333 2/2/2021
1.0.44 583,823 1/24/2021
1.0.43 470,098 1/24/2021
1.0.42 469,716 1/23/2021
1.0.41 527,155 1/20/2021
1.0.40 880,511 1/20/2021
1.0.39 498,193 1/18/2021
1.0.38 469,679 1/18/2021
1.0.37 907,653 1/16/2021
1.0.36 997,465 12/16/2020
1.0.35 934,919 12/14/2020
1.0.34 912,698 12/9/2020
1.0.33 882,791 12/6/2020
1.0.32 470,096 12/2/2020
1.0.31 880,801 12/2/2020
1.0.30 909,088 12/1/2020
1.0.29 1,069,422 11/12/2020
1.0.29-atestpub 2,482 11/11/2020
1.0.28 910,123 10/11/2020
1.0.27 991,906 9/9/2020
1.0.26 908,681 9/3/2020
1.0.25 498,408 8/20/2020
1.0.24 964,373 8/9/2020
1.0.23 498,691 7/28/2020
1.0.22 497,653 7/19/2020
1.0.21 524,839 7/6/2020
1.0.20 964,816 6/6/2020
1.0.19 909,849 6/4/2020
1.0.18 526,236 5/29/2020
1.0.17 937,029 5/21/2020
1.0.16 881,653 5/17/2020
1.0.15 935,782 5/12/2020
1.0.14 990,229 5/4/2020
1.0.13 885,729 4/24/2020
1.0.12 888,454 4/22/2020
1.0.11 881,449 4/22/2020
1.0.10 881,477 4/21/2020
1.0.9 910,628 4/18/2020
1.0.8 497,693 4/16/2020
1.0.7 470,506 4/16/2020
1.0.6 903,656 4/15/2020
1.0.5 906,243 4/11/2020
1.0.4 905,143 4/3/2020
1.0.3 469,997 4/1/2020
1.0.2 892,079 3/27/2020
1.0.1 891,090 3/22/2020
1.0.0 473,374 3/22/2020

Removed obsoete.