Ecng.Collections 1.0.269

dotnet add package Ecng.Collections --version 1.0.269
                    
NuGet\Install-Package Ecng.Collections -Version 1.0.269
                    
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.269" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Ecng.Collections" Version="1.0.269" />
                    
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.269
                    
#r "nuget: Ecng.Collections, 1.0.269"
                    
#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.269
                    
#: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.269
                    
Install as a Cake Addin
#tool nuget:?package=Ecng.Collections&version=1.0.269
                    
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.269 50 12/26/2025
1.0.268 42 12/26/2025
1.0.267 43 12/26/2025
1.0.266 58 12/26/2025
1.0.265 137 12/25/2025
1.0.264 165 12/25/2025
1.0.263 987 12/22/2025
1.0.262 861 12/21/2025
1.0.261 930 12/19/2025
1.0.260 884 12/19/2025
1.0.259 1,066 12/17/2025
1.0.258 1,179 12/15/2025
1.0.257 901 12/15/2025
1.0.256 864 12/14/2025
1.0.255 1,966 12/12/2025
1.0.254 1,140 12/12/2025
1.0.253 743 12/12/2025
1.0.252 750 12/12/2025
1.0.251 1,100 12/12/2025
1.0.250 1,425 12/2/2025
1.0.249 1,306 12/2/2025
1.0.248 1,299 12/2/2025
1.0.247 935 11/30/2025
1.0.246 775 11/29/2025
1.0.245 762 11/28/2025
1.0.244 783 11/28/2025
1.0.243 1,525 11/27/2025
1.0.242 21,260 11/24/2025
1.0.241 23,016 11/24/2025
1.0.240 27,778 11/23/2025
1.0.239 33,192 11/22/2025
1.0.238 51,243 11/20/2025
1.0.237 74,272 11/18/2025
1.0.236 74,955 11/18/2025
1.0.235 117,708 11/13/2025
1.0.234 150,358 11/10/2025
1.0.233 191,033 11/1/2025
1.0.232 190,277 10/28/2025
1.0.231 190,233 10/27/2025
1.0.230 190,112 10/27/2025
1.0.229 190,046 10/25/2025
1.0.228 240,512 10/3/2025
1.0.227 240,575 9/28/2025
1.0.226 240,324 9/25/2025
1.0.225 264,017 8/30/2025
1.0.224 238,794 7/13/2025
1.0.223 230,318 7/13/2025
1.0.222 230,337 7/12/2025
1.0.221 231,565 7/8/2025
1.0.220 231,122 7/4/2025
1.0.219 230,396 7/2/2025
1.0.218 235,288 6/16/2025
1.0.217 230,559 6/9/2025
1.0.216 230,428 6/8/2025
1.0.215 232,071 5/21/2025
1.0.214 230,531 5/17/2025
1.0.213 232,145 5/12/2025
1.0.212 230,460 5/12/2025
1.0.211 232,905 4/17/2025
1.0.210 235,541 3/22/2025
1.0.209 230,431 3/20/2025
1.0.208 230,378 3/20/2025
1.0.207 230,413 3/19/2025
1.0.206 235,567 2/26/2025
1.0.205 230,492 2/26/2025
1.0.204 238,908 2/5/2025
1.0.203 234,413 1/21/2025
1.0.202 233,772 1/14/2025
1.0.201 232,611 1/12/2025
1.0.200 231,046 1/10/2025
1.0.199 234,703 12/27/2024
1.0.198 231,515 11/20/2024
1.0.197 234,002 11/18/2024
1.0.196 232,329 11/7/2024
1.0.195 231,718 10/19/2024
1.0.194 233,575 10/12/2024
1.0.193 234,130 10/5/2024
1.0.192 235,234 9/18/2024
1.0.191 230,514 9/17/2024
1.0.190 234,929 9/3/2024
1.0.189 230,580 9/1/2024
1.0.188 244,678 6/12/2024
1.0.187 233,413 5/28/2024
1.0.186 234,165 5/4/2024
1.0.185 232,848 4/23/2024
1.0.184 231,927 4/21/2024
1.0.183 230,765 4/14/2024
1.0.182 236,113 3/28/2024
1.0.181 230,695 3/17/2024
1.0.180 234,120 2/23/2024
1.0.179 230,721 2/23/2024
1.0.178 234,103 2/18/2024
1.0.177 230,695 2/18/2024
1.0.176 230,776 2/16/2024
1.0.175 232,870 2/13/2024
1.0.174 232,599 2/8/2024
1.0.173 233,042 2/5/2024
1.0.172 230,759 2/4/2024
1.0.171 233,291 1/23/2024
1.0.170 230,855 1/23/2024
1.0.169 232,564 1/12/2024
1.0.168 235,992 1/2/2024
1.0.167 231,077 12/29/2023
1.0.166 249,263 11/12/2023
1.0.165 642,383 11/10/2023
1.0.164 231,041 11/10/2023
1.0.163 642,081 11/9/2023
1.0.162 642,978 11/3/2023
1.0.161 641,920 11/1/2023
1.0.160 641,977 11/1/2023
1.0.159 667,323 9/8/2023
1.0.158 642,397 9/8/2023
1.0.157 642,643 9/3/2023
1.0.156 642,908 8/21/2023
1.0.155 232,317 8/14/2023
1.0.154 643,428 8/10/2023
1.0.153 683,075 6/29/2023
1.0.152 657,502 5/27/2023
1.0.151 232,006 5/21/2023
1.0.150 232,111 5/19/2023
1.0.149 668,496 5/8/2023
1.0.148 648,427 4/21/2023
1.0.147 694,112 4/3/2023
1.0.146 650,594 3/13/2023
1.0.145 662,433 3/6/2023
1.0.144 644,563 2/26/2023
1.0.143 248,488 2/21/2023
1.0.142 232,902 2/20/2023
1.0.141 234,168 2/15/2023
1.0.140 232,912 2/14/2023
1.0.139 676,406 2/9/2023
1.0.138 249,336 2/7/2023
1.0.137 644,430 2/4/2023
1.0.136 664,500 2/2/2023
1.0.135 660,784 1/30/2023
1.0.134 238,931 1/18/2023
1.0.133 688,156 12/30/2022
1.0.132 646,465 12/23/2022
1.0.131 664,899 12/12/2022
1.0.130 667,529 12/4/2022
1.0.129 644,978 12/4/2022
1.0.128 645,725 11/30/2022
1.0.127 234,110 11/29/2022
1.0.126 234,285 11/28/2022
1.0.125 649,208 11/18/2022
1.0.124 672,475 11/11/2022
1.0.123 645,259 11/11/2022
1.0.122 234,355 11/10/2022
1.0.121 645,532 11/5/2022
1.0.120 646,883 11/4/2022
1.0.119 668,972 11/1/2022
1.0.118 669,258 10/16/2022
1.0.117 652,515 9/10/2022
1.0.116 696,083 9/8/2022
1.0.115 645,786 9/8/2022
1.0.114 234,960 9/8/2022
1.0.113 648,125 9/4/2022
1.0.112 324,559 8/24/2022
1.0.111 655,190 8/8/2022
1.0.110 648,861 7/26/2022
1.0.109 646,002 7/26/2022
1.0.108 698,481 7/19/2022
1.0.107 280,022 7/18/2022
1.0.106 240,083 7/8/2022
1.0.105 650,216 6/18/2022
1.0.104 646,030 6/6/2022
1.0.103 742,586 4/30/2022
1.0.102 646,298 4/20/2022
1.0.101 646,350 4/10/2022
1.0.100 646,323 4/7/2022
1.0.99 646,247 4/7/2022
1.0.98 646,434 4/2/2022
1.0.97 246,805 3/29/2022
1.0.96 238,378 3/27/2022
1.0.95 521,459 1/24/2022
1.0.94 805,269 12/29/2021
1.0.93 672,541 12/20/2021
1.0.92 645,954 12/13/2021
1.0.91 702,080 12/6/2021
1.0.90 236,599 12/2/2021
1.0.89 673,671 11/29/2021
1.0.88 672,266 11/22/2021
1.0.87 233,416 11/17/2021
1.0.86 674,094 11/13/2021
1.0.85 236,858 11/10/2021
1.0.84 644,424 11/9/2021
1.0.83 295,989 11/5/2021
1.0.82 646,159 11/4/2021
1.0.81 644,310 11/4/2021
1.0.80 644,222 11/3/2021
1.0.79 644,474 10/30/2021
1.0.78 675,719 10/21/2021
1.0.77 644,901 10/17/2021
1.0.76 705,642 10/14/2021
1.0.75 655,534 10/13/2021
1.0.74 644,493 10/12/2021
1.0.73 676,124 10/11/2021
1.0.72 644,326 10/9/2021
1.0.71 679,488 10/7/2021
1.0.70 681,561 10/7/2021
1.0.69 644,444 10/7/2021
1.0.68 233,588 10/6/2021
1.0.67 644,567 9/28/2021
1.0.66 678,299 9/23/2021
1.0.65 646,201 9/10/2021
1.0.64 644,302 9/9/2021
1.0.63 644,321 9/8/2021
1.0.62 644,437 9/8/2021
1.0.61 675,209 9/6/2021
1.0.60 233,786 8/31/2021
1.0.59 233,555 8/30/2021
1.0.58 677,485 7/31/2021
1.0.57 704,017 7/30/2021
1.0.56 644,770 7/26/2021
1.0.55 733,346 7/5/2021
1.0.54 233,795 7/1/2021
1.0.53 706,855 6/4/2021
1.0.52 734,575 4/26/2021
1.0.51 675,155 4/19/2021
1.0.50 793,156 4/7/2021
1.0.49 674,363 4/3/2021
1.0.48 822,350 3/22/2021
1.0.47 756,200 3/4/2021
1.0.46 677,517 2/26/2021
1.0.45 811,499 2/2/2021
1.0.44 347,963 1/24/2021
1.0.43 234,258 1/24/2021
1.0.42 233,887 1/23/2021
1.0.41 291,306 1/20/2021
1.0.40 644,672 1/20/2021
1.0.39 262,356 1/18/2021
1.0.38 233,837 1/18/2021
1.0.37 671,819 1/16/2021
1.0.36 761,628 12/16/2020
1.0.35 699,119 12/14/2020
1.0.34 676,888 12/9/2020
1.0.33 646,967 12/6/2020
1.0.32 234,278 12/2/2020
1.0.31 644,994 12/2/2020
1.0.30 673,256 12/1/2020
1.0.29 833,580 11/12/2020
1.0.29-atestpub 2,466 11/11/2020
1.0.28 674,277 10/11/2020
1.0.27 756,054 9/9/2020
1.0.26 672,832 9/3/2020
1.0.25 262,585 8/20/2020
1.0.24 728,538 8/9/2020
1.0.23 262,864 7/28/2020
1.0.22 261,819 7/19/2020
1.0.21 289,017 7/6/2020
1.0.20 728,966 6/6/2020
1.0.19 674,025 6/4/2020
1.0.18 290,374 5/29/2020
1.0.17 701,201 5/21/2020
1.0.16 645,817 5/17/2020
1.0.15 699,960 5/12/2020
1.0.14 754,375 5/4/2020
1.0.13 649,893 4/24/2020
1.0.12 652,613 4/22/2020
1.0.11 645,616 4/22/2020
1.0.10 645,652 4/21/2020
1.0.9 674,811 4/18/2020
1.0.8 261,850 4/16/2020
1.0.7 234,675 4/16/2020
1.0.6 667,802 4/15/2020
1.0.5 670,405 4/11/2020
1.0.4 669,300 4/3/2020
1.0.3 234,158 4/1/2020
1.0.2 656,223 3/27/2020
1.0.1 655,251 3/22/2020
1.0.0 237,524 3/22/2020