Ecng.Collections 1.0.274

There is a newer version of this package available.
See the version list below for details.
dotnet add package Ecng.Collections --version 1.0.274
                    
NuGet\Install-Package Ecng.Collections -Version 1.0.274
                    
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.274" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Ecng.Collections" Version="1.0.274" />
                    
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.274
                    
#r "nuget: Ecng.Collections, 1.0.274"
                    
#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.274
                    
#: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.274
                    
Install as a Cake Addin
#tool nuget:?package=Ecng.Collections&version=1.0.274
                    
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>
{
    SyncObject 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.278 0 1/18/2026
1.0.277 436 1/14/2026
1.0.276 451 1/13/2026
1.0.275 475 1/13/2026
1.0.274 1,198 1/9/2026
1.0.273 876 1/9/2026
1.0.272 3,374 1/4/2026
1.0.271 2,259 12/30/2025
1.0.270 793 12/29/2025
1.0.269 1,216 12/26/2025
1.0.268 801 12/26/2025
1.0.267 783 12/26/2025
1.0.266 800 12/26/2025
1.0.265 857 12/25/2025
1.0.264 874 12/25/2025
1.0.263 1,371 12/22/2025
1.0.262 874 12/21/2025
1.0.261 942 12/19/2025
1.0.260 902 12/19/2025
1.0.259 5,874 12/17/2025
1.0.258 20,455 12/15/2025
1.0.257 20,365 12/15/2025
1.0.256 26,619 12/14/2025
1.0.255 47,440 12/12/2025
1.0.254 46,755 12/12/2025
1.0.253 46,364 12/12/2025
1.0.252 46,366 12/12/2025
1.0.251 47,106 12/12/2025
1.0.250 110,257 12/2/2025
1.0.249 110,486 12/2/2025
1.0.248 111,258 12/2/2025
1.0.247 126,838 11/30/2025
1.0.246 129,824 11/29/2025
1.0.245 132,004 11/28/2025
1.0.244 132,703 11/28/2025
1.0.243 136,522 11/27/2025
1.0.242 156,258 11/24/2025
1.0.241 158,009 11/24/2025
1.0.240 162,773 11/23/2025
1.0.239 168,195 11/22/2025
1.0.238 186,279 11/20/2025
1.0.237 209,279 11/18/2025
1.0.236 209,952 11/18/2025
1.0.235 252,707 11/13/2025
1.0.234 285,371 11/10/2025
1.0.233 326,030 11/1/2025
1.0.232 325,275 10/28/2025
1.0.231 325,243 10/27/2025
1.0.230 325,106 10/27/2025
1.0.229 325,041 10/25/2025
1.0.228 375,502 10/3/2025
1.0.227 375,579 9/28/2025
1.0.226 375,313 9/25/2025
1.0.225 399,258 8/30/2025
1.0.224 373,805 7/13/2025
1.0.223 365,309 7/13/2025
1.0.222 365,330 7/12/2025
1.0.221 366,590 7/8/2025
1.0.220 366,121 7/4/2025
1.0.219 365,401 7/2/2025
1.0.218 370,281 6/16/2025
1.0.217 365,553 6/9/2025
1.0.216 365,416 6/8/2025
1.0.215 367,059 5/21/2025
1.0.214 365,526 5/17/2025
1.0.213 367,129 5/12/2025
1.0.212 365,445 5/12/2025
1.0.211 367,901 4/17/2025
1.0.210 370,544 3/22/2025
1.0.209 365,413 3/20/2025
1.0.208 365,353 3/20/2025
1.0.207 365,398 3/19/2025
1.0.206 370,579 2/26/2025
1.0.205 365,481 2/26/2025
1.0.204 373,909 2/5/2025
1.0.203 369,403 1/21/2025
1.0.202 368,754 1/14/2025
1.0.201 367,595 1/12/2025
1.0.200 366,041 1/10/2025
1.0.199 369,704 12/27/2024
1.0.198 366,506 11/20/2024
1.0.197 368,991 11/18/2024
1.0.196 367,318 11/7/2024
1.0.195 366,706 10/19/2024
1.0.194 368,565 10/12/2024
1.0.193 369,112 10/5/2024
1.0.192 370,217 9/18/2024
1.0.191 365,502 9/17/2024
1.0.190 369,914 9/3/2024
1.0.189 365,563 9/1/2024
1.0.188 379,674 6/12/2024
1.0.187 368,413 5/28/2024
1.0.186 369,163 5/4/2024
1.0.185 367,847 4/23/2024
1.0.184 366,928 4/21/2024
1.0.183 365,753 4/14/2024
1.0.182 371,119 3/28/2024
1.0.181 365,698 3/17/2024
1.0.180 369,114 2/23/2024
1.0.179 365,719 2/23/2024
1.0.178 369,101 2/18/2024
1.0.177 365,688 2/18/2024
1.0.176 365,765 2/16/2024
1.0.175 367,861 2/13/2024
1.0.174 367,582 2/8/2024
1.0.173 368,046 2/5/2024
1.0.172 365,739 2/4/2024
1.0.171 368,286 1/23/2024
1.0.170 365,855 1/23/2024
1.0.169 367,559 1/12/2024
1.0.168 370,977 1/2/2024
1.0.167 366,071 12/29/2023
1.0.166 384,259 11/12/2023
1.0.165 777,376 11/10/2023
1.0.164 366,039 11/10/2023
1.0.163 777,069 11/9/2023
1.0.162 777,969 11/3/2023
1.0.161 776,903 11/1/2023
1.0.160 776,957 11/1/2023
1.0.159 802,310 9/8/2023
1.0.158 777,380 9/8/2023
1.0.157 777,625 9/3/2023
1.0.156 777,888 8/21/2023
1.0.155 367,296 8/14/2023
1.0.154 778,412 8/10/2023
1.0.153 818,065 6/29/2023
1.0.152 792,482 5/27/2023
1.0.151 366,983 5/21/2023
1.0.150 367,098 5/19/2023
1.0.149 803,473 5/8/2023
1.0.148 783,399 4/21/2023
1.0.147 829,104 4/3/2023
1.0.146 785,567 3/13/2023
1.0.145 797,407 3/6/2023
1.0.144 779,546 2/26/2023
1.0.143 383,482 2/21/2023
1.0.142 367,884 2/20/2023
1.0.141 369,146 2/15/2023
1.0.140 367,900 2/14/2023
1.0.139 811,379 2/9/2023
1.0.138 384,321 2/7/2023
1.0.137 779,428 2/4/2023
1.0.136 799,488 2/2/2023
1.0.135 795,777 1/30/2023
1.0.134 373,923 1/18/2023
1.0.133 823,133 12/30/2022
1.0.132 781,462 12/23/2022
1.0.131 799,891 12/12/2022
1.0.130 802,515 12/4/2022
1.0.129 779,970 12/4/2022
1.0.128 780,721 11/30/2022
1.0.127 369,104 11/29/2022
1.0.126 369,278 11/28/2022
1.0.125 784,197 11/18/2022
1.0.124 807,461 11/11/2022
1.0.123 780,252 11/11/2022
1.0.122 369,344 11/10/2022
1.0.121 780,528 11/5/2022
1.0.120 781,868 11/4/2022
1.0.119 803,974 11/1/2022
1.0.118 804,267 10/16/2022
1.0.117 787,512 9/10/2022
1.0.116 831,082 9/8/2022
1.0.115 780,772 9/8/2022
1.0.114 369,954 9/8/2022
1.0.113 783,112 9/4/2022
1.0.112 459,550 8/24/2022
1.0.111 790,184 8/8/2022
1.0.110 783,848 7/26/2022
1.0.109 781,002 7/26/2022
1.0.108 833,467 7/19/2022
1.0.107 415,004 7/18/2022
1.0.106 375,081 7/8/2022
1.0.105 785,205 6/18/2022
1.0.104 781,024 6/6/2022
1.0.103 877,576 4/30/2022
1.0.102 781,282 4/20/2022
1.0.101 781,333 4/10/2022
1.0.100 781,307 4/7/2022
1.0.99 781,228 4/7/2022
1.0.98 781,416 4/2/2022
1.0.97 381,794 3/29/2022
1.0.96 373,372 3/27/2022
1.0.95 656,495 1/24/2022
1.0.94 940,255 12/29/2021
1.0.93 807,530 12/20/2021
1.0.92 780,951 12/13/2021
1.0.91 837,062 12/6/2021
1.0.90 371,592 12/2/2021
1.0.89 808,651 11/29/2021
1.0.88 807,251 11/22/2021
1.0.87 368,402 11/17/2021
1.0.86 809,080 11/13/2021
1.0.85 371,842 11/10/2021
1.0.84 779,411 11/9/2021
1.0.83 430,973 11/5/2021
1.0.82 781,146 11/4/2021
1.0.81 779,305 11/4/2021
1.0.80 779,217 11/3/2021
1.0.79 779,461 10/30/2021
1.0.78 810,708 10/21/2021
1.0.77 779,889 10/17/2021
1.0.76 840,641 10/14/2021
1.0.75 790,525 10/13/2021
1.0.74 779,478 10/12/2021
1.0.73 811,130 10/11/2021
1.0.72 779,310 10/9/2021
1.0.71 814,484 10/7/2021
1.0.70 816,551 10/7/2021
1.0.69 779,430 10/7/2021
1.0.68 368,567 10/6/2021
1.0.67 779,563 9/28/2021
1.0.66 813,286 9/23/2021
1.0.65 781,185 9/10/2021
1.0.64 779,294 9/9/2021
1.0.63 779,307 9/8/2021
1.0.62 779,428 9/8/2021
1.0.61 810,191 9/6/2021
1.0.60 368,776 8/31/2021
1.0.59 368,553 8/30/2021
1.0.58 812,486 7/31/2021
1.0.57 839,001 7/30/2021
1.0.56 779,765 7/26/2021
1.0.55 868,345 7/5/2021
1.0.54 368,788 7/1/2021
1.0.53 841,872 6/4/2021
1.0.52 869,565 4/26/2021
1.0.51 810,132 4/19/2021
1.0.50 928,146 4/7/2021
1.0.49 809,346 4/3/2021
1.0.48 957,350 3/22/2021
1.0.47 891,209 3/4/2021
1.0.46 812,518 2/26/2021
1.0.45 946,501 2/2/2021
1.0.44 482,969 1/24/2021
1.0.43 369,249 1/24/2021
1.0.42 368,864 1/23/2021
1.0.41 426,287 1/20/2021
1.0.40 779,658 1/20/2021
1.0.39 397,345 1/18/2021
1.0.38 368,828 1/18/2021
1.0.37 806,812 1/16/2021
1.0.36 896,620 12/16/2020
1.0.35 834,087 12/14/2020
1.0.34 811,864 12/9/2020
1.0.33 781,940 12/6/2020
1.0.32 369,252 12/2/2020
1.0.31 779,974 12/2/2020
1.0.30 808,245 12/1/2020
1.0.29 968,572 11/12/2020
1.0.29-atestpub 2,475 11/11/2020
1.0.28 809,264 10/11/2020
1.0.27 891,044 9/9/2020
1.0.26 807,834 9/3/2020
1.0.25 397,566 8/20/2020
1.0.24 863,529 8/9/2020
1.0.23 397,846 7/28/2020
1.0.22 396,798 7/19/2020
1.0.21 424,007 7/6/2020
1.0.20 863,971 6/6/2020
1.0.19 809,008 6/4/2020
1.0.18 425,383 5/29/2020
1.0.17 836,186 5/21/2020
1.0.16 780,800 5/17/2020
1.0.15 834,949 5/12/2020
1.0.14 889,379 5/4/2020
1.0.13 784,882 4/24/2020
1.0.12 787,598 4/22/2020
1.0.11 780,610 4/22/2020
1.0.10 780,632 4/21/2020
1.0.9 809,791 4/18/2020
1.0.8 396,846 4/16/2020
1.0.7 369,658 4/16/2020
1.0.6 802,801 4/15/2020
1.0.5 805,399 4/11/2020
1.0.4 804,285 4/3/2020
1.0.3 369,142 4/1/2020
1.0.2 791,213 3/27/2020
1.0.1 790,252 3/22/2020
1.0.0 372,534 3/22/2020