Ecng.Collections 1.0.263

dotnet add package Ecng.Collections --version 1.0.263
                    
NuGet\Install-Package Ecng.Collections -Version 1.0.263
                    
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.263" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Ecng.Collections" Version="1.0.263" />
                    
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.263
                    
#r "nuget: Ecng.Collections, 1.0.263"
                    
#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.263
                    
#: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.263
                    
Install as a Cake Addin
#tool nuget:?package=Ecng.Collections&version=1.0.263
                    
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 (7)

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.263 333 12/22/2025
1.0.262 430 12/21/2025
1.0.261 607 12/19/2025
1.0.260 575 12/19/2025
1.0.259 919 12/17/2025
1.0.258 1,178 12/15/2025
1.0.257 900 12/15/2025
1.0.256 861 12/14/2025
1.0.255 1,963 12/12/2025
1.0.254 1,134 12/12/2025
1.0.253 740 12/12/2025
1.0.252 746 12/12/2025
1.0.251 1,098 12/12/2025
1.0.250 1,419 12/2/2025
1.0.249 1,305 12/2/2025
1.0.248 1,298 12/2/2025
1.0.247 931 11/30/2025
1.0.246 771 11/29/2025
1.0.245 758 11/28/2025
1.0.244 780 11/28/2025
1.0.243 850 11/27/2025
1.0.242 913 11/24/2025
1.0.241 842 11/24/2025
1.0.240 1,762 11/23/2025
1.0.239 7,176 11/22/2025
1.0.238 25,218 11/20/2025
1.0.237 48,255 11/18/2025
1.0.236 48,939 11/18/2025
1.0.235 91,693 11/13/2025
1.0.234 124,336 11/10/2025
1.0.233 165,019 11/1/2025
1.0.232 164,261 10/28/2025
1.0.231 164,205 10/27/2025
1.0.230 164,099 10/27/2025
1.0.229 164,033 10/25/2025
1.0.228 214,501 10/3/2025
1.0.227 214,562 9/28/2025
1.0.226 214,311 9/25/2025
1.0.225 237,972 8/30/2025
1.0.224 212,776 7/13/2025
1.0.223 204,306 7/13/2025
1.0.222 204,325 7/12/2025
1.0.221 205,553 7/8/2025
1.0.220 205,110 7/4/2025
1.0.219 204,384 7/2/2025
1.0.218 209,270 6/16/2025
1.0.217 204,543 6/9/2025
1.0.216 204,413 6/8/2025
1.0.215 206,056 5/21/2025
1.0.214 204,517 5/17/2025
1.0.213 206,133 5/12/2025
1.0.212 204,449 5/12/2025
1.0.211 206,888 4/17/2025
1.0.210 209,529 3/22/2025
1.0.209 204,419 3/20/2025
1.0.208 204,365 3/20/2025
1.0.207 204,403 3/19/2025
1.0.206 209,554 2/26/2025
1.0.205 204,482 2/26/2025
1.0.204 212,894 2/5/2025
1.0.203 208,402 1/21/2025
1.0.202 207,754 1/14/2025
1.0.201 206,592 1/12/2025
1.0.200 205,028 1/10/2025
1.0.199 208,690 12/27/2024
1.0.198 205,497 11/20/2024
1.0.197 207,987 11/18/2024
1.0.196 206,311 11/7/2024
1.0.195 205,703 10/19/2024
1.0.194 207,556 10/12/2024
1.0.193 208,110 10/5/2024
1.0.192 209,217 9/18/2024
1.0.191 204,496 9/17/2024
1.0.190 208,912 9/3/2024
1.0.189 204,557 9/1/2024
1.0.188 218,658 6/12/2024
1.0.187 207,393 5/28/2024
1.0.186 208,147 5/4/2024
1.0.185 206,829 4/23/2024
1.0.184 205,912 4/21/2024
1.0.183 204,745 4/14/2024
1.0.182 210,098 3/28/2024
1.0.181 204,685 3/17/2024
1.0.180 208,107 2/23/2024
1.0.179 204,715 2/23/2024
1.0.178 208,093 2/18/2024
1.0.177 204,689 2/18/2024
1.0.176 204,766 2/16/2024
1.0.175 206,858 2/13/2024
1.0.174 206,584 2/8/2024
1.0.173 207,024 2/5/2024
1.0.172 204,743 2/4/2024
1.0.171 207,277 1/23/2024
1.0.170 204,834 1/23/2024
1.0.169 206,550 1/12/2024
1.0.168 209,975 1/2/2024
1.0.167 205,062 12/29/2023
1.0.166 223,248 11/12/2023
1.0.165 616,374 11/10/2023
1.0.164 205,020 11/10/2023
1.0.163 616,068 11/9/2023
1.0.162 616,964 11/3/2023
1.0.161 615,906 11/1/2023
1.0.160 615,968 11/1/2023
1.0.159 641,309 9/8/2023
1.0.158 616,384 9/8/2023
1.0.157 616,631 9/3/2023
1.0.156 616,892 8/21/2023
1.0.155 206,302 8/14/2023
1.0.154 617,408 8/10/2023
1.0.153 657,058 6/29/2023
1.0.152 631,487 5/27/2023
1.0.151 205,991 5/21/2023
1.0.150 206,093 5/19/2023
1.0.149 642,478 5/8/2023
1.0.148 622,408 4/21/2023
1.0.147 668,096 4/3/2023
1.0.146 624,579 3/13/2023
1.0.145 636,414 3/6/2023
1.0.144 618,542 2/26/2023
1.0.143 222,467 2/21/2023
1.0.142 206,889 2/20/2023
1.0.141 208,154 2/15/2023
1.0.140 206,895 2/14/2023
1.0.139 650,385 2/9/2023
1.0.138 223,316 2/7/2023
1.0.137 618,410 2/4/2023
1.0.136 638,485 2/2/2023
1.0.135 634,765 1/30/2023
1.0.134 212,912 1/18/2023
1.0.133 662,132 12/30/2022
1.0.132 620,450 12/23/2022
1.0.131 638,888 12/12/2022
1.0.130 641,513 12/4/2022
1.0.129 618,967 12/4/2022
1.0.128 619,712 11/30/2022
1.0.127 208,102 11/29/2022
1.0.126 208,275 11/28/2022
1.0.125 623,198 11/18/2022
1.0.124 646,456 11/11/2022
1.0.123 619,248 11/11/2022
1.0.122 208,339 11/10/2022
1.0.121 619,516 11/5/2022
1.0.120 620,865 11/4/2022
1.0.119 642,954 11/1/2022
1.0.118 643,240 10/16/2022
1.0.117 626,501 9/10/2022
1.0.116 670,067 9/8/2022
1.0.115 619,775 9/8/2022
1.0.114 208,943 9/8/2022
1.0.113 622,112 9/4/2022
1.0.112 298,542 8/24/2022
1.0.111 629,177 8/8/2022
1.0.110 622,843 7/26/2022
1.0.109 619,989 7/26/2022
1.0.108 672,463 7/19/2022
1.0.107 254,003 7/18/2022
1.0.106 214,064 7/8/2022
1.0.105 624,196 6/18/2022
1.0.104 620,013 6/6/2022
1.0.103 716,569 4/30/2022
1.0.102 620,275 4/20/2022
1.0.101 620,332 4/10/2022
1.0.100 620,302 4/7/2022
1.0.99 620,228 4/7/2022
1.0.98 620,418 4/2/2022
1.0.97 220,785 3/29/2022
1.0.96 212,361 3/27/2022
1.0.95 495,438 1/24/2022
1.0.94 779,258 12/29/2021
1.0.93 646,525 12/20/2021
1.0.92 619,942 12/13/2021
1.0.91 676,061 12/6/2021
1.0.90 210,588 12/2/2021
1.0.89 647,653 11/29/2021
1.0.88 646,250 11/22/2021
1.0.87 207,399 11/17/2021
1.0.86 648,082 11/13/2021
1.0.85 210,845 11/10/2021
1.0.84 618,406 11/9/2021
1.0.83 269,971 11/5/2021
1.0.82 620,140 11/4/2021
1.0.81 618,291 11/4/2021
1.0.80 618,202 11/3/2021
1.0.79 618,451 10/30/2021
1.0.78 649,695 10/21/2021
1.0.77 618,878 10/17/2021
1.0.76 679,623 10/14/2021
1.0.75 629,517 10/13/2021
1.0.74 618,474 10/12/2021
1.0.73 650,110 10/11/2021
1.0.72 618,305 10/9/2021
1.0.71 653,466 10/7/2021
1.0.70 655,541 10/7/2021
1.0.69 618,425 10/7/2021
1.0.68 207,571 10/6/2021
1.0.67 618,546 9/28/2021
1.0.66 652,280 9/23/2021
1.0.65 620,179 9/10/2021
1.0.64 618,287 9/9/2021
1.0.63 618,307 9/8/2021
1.0.62 618,420 9/8/2021
1.0.61 649,192 9/6/2021
1.0.60 207,771 8/31/2021
1.0.59 207,541 8/30/2021
1.0.58 651,471 7/31/2021
1.0.57 678,000 7/30/2021
1.0.56 618,752 7/26/2021
1.0.55 707,326 7/5/2021
1.0.54 207,781 7/1/2021
1.0.53 680,832 6/4/2021
1.0.52 708,552 4/26/2021
1.0.51 649,135 4/19/2021
1.0.50 767,125 4/7/2021
1.0.49 648,340 4/3/2021
1.0.48 796,328 3/22/2021
1.0.47 730,175 3/4/2021
1.0.46 651,498 2/26/2021
1.0.45 785,472 2/2/2021
1.0.44 321,941 1/24/2021
1.0.43 208,235 1/24/2021
1.0.42 207,875 1/23/2021
1.0.41 265,288 1/20/2021
1.0.40 618,654 1/20/2021
1.0.39 236,335 1/18/2021
1.0.38 207,825 1/18/2021
1.0.37 645,804 1/16/2021
1.0.36 735,603 12/16/2020
1.0.35 673,093 12/14/2020
1.0.34 650,868 12/9/2020
1.0.33 620,947 12/6/2020
1.0.32 208,260 12/2/2020
1.0.31 618,969 12/2/2020
1.0.30 647,236 12/1/2020
1.0.29 807,565 11/12/2020
1.0.29-atestpub 2,463 11/11/2020
1.0.28 648,258 10/11/2020
1.0.27 730,042 9/9/2020
1.0.26 646,815 9/3/2020
1.0.25 236,565 8/20/2020
1.0.24 702,519 8/9/2020
1.0.23 236,846 7/28/2020
1.0.22 235,804 7/19/2020
1.0.21 263,003 7/6/2020
1.0.20 702,952 6/6/2020
1.0.19 648,007 6/4/2020
1.0.18 264,356 5/29/2020
1.0.17 675,185 5/21/2020
1.0.16 619,803 5/17/2020
1.0.15 673,943 5/12/2020
1.0.14 728,358 5/4/2020
1.0.13 623,878 4/24/2020
1.0.12 626,596 4/22/2020
1.0.11 619,599 4/22/2020
1.0.10 619,630 4/21/2020
1.0.9 648,798 4/18/2020
1.0.8 235,829 4/16/2020
1.0.7 208,662 4/16/2020
1.0.6 641,786 4/15/2020
1.0.5 644,389 4/11/2020
1.0.4 643,281 4/3/2020
1.0.3 208,145 4/1/2020
1.0.2 630,209 3/27/2020
1.0.1 629,235 3/22/2020
1.0.0 211,504 3/22/2020