MicroElements source only package: Collection extensions: NotNull, Iterate, Execute, WhereNotNull, Materialize, IncludeByWildcardPatterns, ExcludeByWildcardPatterns. Special collections: Cache, TwoLayerCache, PollingCache.
$ dotnet add package MicroElements.Collections.SourcesMicroElements source only package: Collection extensions: NotNull, Iterate, Materialize. Special collections: TwoLayerCache.
Returns not null (empty) enumeration if input is null.
string? GetFirstValue(IEnumerable<string>? optionalValues) =>
optionalValues
.NotNull()
.FirstOrDefault();
Iterates values and executes action for each value.
It's like List.ForEach but works with lazy enumerations and does not forces additional allocations.
// Iterates values and outputs to console.
Enumerable
.Range(1, 100_000)
.Iterate(Console.WriteLine);
Materializes source enumeration and allows to see intermediate results without changing execute chain. MaterializeDebug is the same as Materialize but works only in Debug mode and does not affect performance for Release builds.
Enumerable
.Range(1, 10)
.Materialize(values => { /*set breakpoint here*/ })
.Iterate(Console.WriteLine);
Represents ThreadSafe cache that holds only limited number of items. Can be used as drop in replacement for ConcurrentDictionary.
Use it when you need simple cache but with memory limit.
Notes: