Table of Contents

Bodu.Collections.Generic.Extensions Namespace

Package
Bodu.Core 1.0.1

Bodu.Core

Purpose

Bodu.Collections.Generic.Extensions holds the sequence-shaping helpers for IEnumerable<T>, IList<T>, and IDictionary<TKey, TValue> - recursive selection, batched enumeration, sliding windows, and pluggable randomness-driven shuffles.

Key types

Tip

Looking for sequence producers - Range, NextWhile, or named series such as Fibonacci? Those live on SequenceGenerator in the dedicated Bodu.Sequences namespace.

Example

using Bodu.Collections.Generic.Extensions;

// Batched enumeration over an IEnumerable<T>.
foreach (IEnumerable<int> batch in Enumerable.Range(0, 100).Batch(size: 16, selector: static x => x))
    Process(batch);

// Recursive selection.
IEnumerable<DirectoryInfo> allDirs = root.EnumerateDirectories()
    .RecursiveSelect(d => d.EnumerateDirectories());

Notes

  • Lazy where possible. Helpers like Batch, RecursiveSelect, and Cache are lazy. Materialise to ToList() / ToArray() when you need a stable snapshot.
  • Argument validation. Every public extension method validates its arguments via ThrowHelper.
  • Packaging. This extension namespace ships in the Bodu.Core package; the concrete collection types in the sibling Bodu.Collections.* namespaces ship in the Bodu.Collections package, except the thread-safe Bodu.Collections.Generic.Concurrent variants, which ship in Bodu.Collections.Concurrent.
  • See also: the Bodu.Core introduction, the companion Bodu.Collections.Extensions namespace, the Bodu.Sequences sequence generators, the Bodu.Extensions date / numeric / string extension surface.

Classes

IDictionaryExtensions

Provides retrieval-and-mutation helpers for IDictionary<TKey, TValue> - get-or-add and add-or-update operations modelled on the ConcurrentDictionary<TKey, TValue> surface but available on any dictionary implementation.

IEnumerableExtensions

Provides deferred-execution combinators over IEnumerable<T> - batching, caching, multi-aggregate fan-out, recursive descent, randomization, and set-membership predicates - that complement the standard LINQ surface for production pipeline code.

IListExtensions

Provides extension methods that add predicate-based search, safe relocation, and bulk replacement operations to any type implementing IList<T>.

SystemRandomAdapter

Adapts a Random instance to the IRandomGenerator interface.

Enums

RandomizationMode

Specifies the available strategies for randomizing a sequence.