Table of Contents

Core Foundations guides

Recipe-style walk-throughs for the Core Foundations package family - Bodu.Core, Bodu.Collections, and Bodu.Collections.Concurrent - organized by namespace. Each guide on this page is a focused walk-through of one headline type.

If you have not yet installed the packages or want the high-level shape of each library, start with the Bodu.Core, Bodu.Collections, and Bodu.Collections.Concurrent introductions and their getting-started pages. New to the many collection types? Read Choosing a collection - a decision guide that maps requirements to the correct type. For the auto-generated API reference, see the Bodu.Collections.Generic namespace page.

These guides anchor the Core Foundations topic: the topic guide landing places them alongside the rest of the topic, and the topic overview carries the package map and install commands.

Note

Three packages share this page. The specialized collection catalogue - the Bodu.Collections.Generic, .Graphs, .Trees, and Bodu.Collections.Probabilistic namespaces below - ships in the Bodu.Collections package (which depends on Bodu.Core); the thread-safe Bodu.Collections.Generic.Concurrent namespace ships in the Bodu.Collections.Concurrent package (which depends on Bodu.Collections). The namespaces are unchanged; only the package boundaries moved. Install with dotnet add package Bodu.Collections / dotnet add package Bodu.Collections.Concurrent. The remaining namespaces on this page ship in Bodu.Core itself.

Namespace map

Namespace What lives here Guides
Bodu.Collections.Generic Bounded ring-backed collections, sets, multisets, and range-keyed lookups - CircularBuffer<T>, Deque<T>, EvictingDictionary<TKey,TValue>, SequencedDictionary<TKey,TValue>, BiDictionary<TKey,TValue>, LayeredDictionary<TKey,TValue>, DefaultingDictionary<TKey,TValue>, Table<TRow,TColumn,TValue>, IndexedPriorityQueue<TElement,TPriority>, IndexedSet<T>, OrderedSet<T>, NavigableSet<T>, NavigableDictionary<TKey,TValue>, Multiset<T>, MultiValueDictionary<TKey,TValue>, RangeDictionary<TKey,TValue>, RangeSet<T>, IntervalTree<T>, IntervalTree<TKey,TValue>, SegmentedBuffer<T>, RingBackedCollection<T> base. Choosing a collection · Circular buffer · Deque · Evicting dictionary · Sequenced dictionary · Bidirectional dictionary · Layered and defaulting dictionaries · Table (two-key map) · Indexed priority queue · Indexed and ordered sets · Navigable set · Navigable dictionary · Multiset · Multi-value dictionary · Range-keyed lookups · Interval tree · Segmented buffer
Bodu.Collections.Generic.Concurrent Thread-safe collection variants - ConcurrentCircularBuffer<T>, ConcurrentHashSet<T>, and the lock-striped ConcurrentEvictingDictionary<TKey,TValue> bounded cache (ships in the Bodu.Collections.Concurrent package). Concurrent collections
Bodu.Collections.Specialized Specialised structures that are not general-purpose containers - the packed BitSet. Bit set
Bodu.Collections.Probabilistic Approximate sketch structures with quantified error bounds - BloomFilter<T> (membership, no false negatives), CountMinSketch<T> (frequencies, never underestimates), HyperLogLog<T> (distinct counts, ~1.04/√m standard error). Probabilistic collections (sketches)
Bodu.Collections.Generic.Graphs Graphs and graph algorithms - Graph<T>, the read-only IReadOnlyGraph<T> / IReadOnlyWeightedGraph<T> views, GraphAlgorithms (BFS/DFS, shortest path, topological sort, connected components), ShortestPathResult<T>, and the DisjointSet<T> union-find. Graphs and graph algorithms
Bodu.Collections.Generic.Trees The trie family and an n-ary tree - Trie / Trie<TValue>, the path-compressed RadixTrie / RadixTrie<TValue>, the multi-pattern AhoCorasickAutomaton / AhoCorasickAutomaton<TValue>, and Tree<T>. Tries and text search · N-ary tree
Bodu.Threading Async coordination primitives - AsyncLock, AsyncSemaphore, AsyncReaderWriterLock, AsyncAutoResetEvent / AsyncManualResetEvent / AsyncCountdownEvent, AsyncLazy<T>, AsyncDebouncer, and RateGate. Async coordination primitives
Bodu.Functional Functional helpers - Memoizer, and the railway primitives Option<T>, Result / Result<T> / ResultError, Either<TLeft,TRight> with Task-based async combinators. Memoization · Options, results, and eithers
Bodu Root namespace primitives - WeekPattern, WorkingDaysOfWeek, IRandomGenerator, XorShiftRandom, ThrowHelper. WeekPattern · Fiscal quarters, working weeks, and weekend providers
Bodu.Buffers Pooled buffer infrastructure - PooledBufferBuilder<T>. Pooled buffer builder
Bodu.Extensions Date, numeric, span, array, string, enum, stream, and comparable extension methods - DateTimeExtensions, DateOnlyExtensions, NumericExtensions, ArrayExtensions, BufferConverter, SpanExtensions, ComparableExtensions, StringExtensions, EnumExtensions, StreamExtensions - the calendar-shape types (CalendarQuarterDefinition, IQuarterDefinitionProvider, FiscalWeekQuarterProvider, IWeekendDefinitionProvider), and the NaturalStringComparer. String extensions · Date and time extensions · Fiscal quarters, working weeks, and weekend providers · Numeric, enum, array, span, and stream extensions · Natural string comparer
Bodu.Collections.Generic.Extensions, Bodu.Collections.Extensions, Bodu.Sequences The LINQ-style operator catalogue (IEnumerableExtensions, IListExtensions, IDictionaryExtensions, RandomizationMode, RecursiveSelectControl), ShuffleHelpers, and SequenceGenerator. Sequence operators and generators
Bodu.Text, Bodu.Xml.Linq Small text and XML helpers used internally. -
(cross-cutting) Which types are safe to share between threads, and how each enumerates under mutation. Thread-safety contracts across Core Foundations

Guides

Bodu.Collections.Generic

Choosing a collection

The decision guide - quick decision tree, per-axis tables, real-world scenarios, and the anti-patterns that come up when picking between similar types.

Circular buffer

Fixed-capacity FIFO ring buffer - single-threaded CircularBuffer<T> and thread-safe ConcurrentCircularBuffer<T>; configurable overwrite-on-full.

Deque

Double-ended queue - Deque<T> with O(1) AddFirst / AddLast / RemoveFirst / RemoveLast; growable or fixed-capacity.

Evicting dictionary

Capacity-bounded key-value store with FIFO, LRU, and LFU eviction policies.

Sequenced dictionary

Insertion- or access-ordered dictionary (Java LinkedHashMap shape) with O(1) First / Last access and TryRemoveFirst / TryRemoveLast.

Bidirectional dictionary

One-to-one map (Guava BiMap shape) with O(1) value-to-key lookup and a live Inverse view sharing the same storage.

Indexed priority queue

Min-heap priority queue with O(1) lookup-by-element and in-place priority updates - for Dijkstra, Prim, and A*.

Indexed and ordered sets

Insertion-ordered unique collections - IndexedSet<T> (unique IList<T>) and OrderedSet<T> (ordered set algebra).

Multiset

A bag that retains duplicates as multiplicity - frequency counting and multiset algebra (sum, union, intersect, except).

Multi-value dictionary

One key to many values without the Dictionary<TKey, List<TValue>> boilerplate; the indexer never returns null.

Range-keyed lookups

Half-open interval keys - Range<T>, RangeDictionary<TKey,TValue>, and RangeSet<T> with union / intersect / except.

Interval tree

Closed intervals that may freely overlap - O(log n + k) stabbing (QueryPoint) and window (QueryOverlaps) queries over a max-endpoint augmented red-black tree; the only range type that stores overlaps.

Segmented buffer

Append-only buffer that grows in fixed-size segments - avoids the array-doubling copy for streams of unknown length.

Navigable set

Sorted set over an order-statistic red-black tree - O(log n) floor/ceiling/higher/lower, rank/select (IndexOf / GetAt), CountInRange, and live ascending/descending/range views.

Navigable dictionary

Key-sorted dictionary over the same order-statistic tree - O(log n) floor/ceiling/higher/lower entry queries, rank/select (IndexOfKey / GetAt), CountInRange, and live ascending/descending/range entry views.

Layered and defaulting dictionaries

Python-shaped dictionary utilities - LayeredDictionary<TKey,TValue> (a first-wins ChainMap view over ordered layers) and DefaultingDictionary<TKey,TValue> (a defaultdict whose indexer materializes and stores factory defaults).

Table (two-key map)

Two-key map (Guava Table shape) whose point is the projections - live Row / Column dictionary views over a row-major store, with an honest O(rows) column-axis cost.

Extending RingBackedCollection<T>

The abstract ring-buffer base behind CircularBuffer<T> and Deque<T> - its protected primitives, the structural-version counter and fail-fast contract, and a worked sliding-window derivation.

Thread-safety contracts

One table across Bodu.Core, Bodu.Collections, and Bodu.Collections.Concurrent: safe, immutable, read-only safe, or unsafe; which reads mutate; fail-fast versus snapshot enumeration.

Bodu.Collections.Generic.Concurrent

Concurrent collections

Thread-safe peers - lock-free ConcurrentCircularBuffer<T> (Vyukov MPMC ring), lock-free split-ordered ConcurrentHashSet<T>, and the lock-striped ConcurrentEvictingDictionary<TKey,TValue> bounded cache with TTL and single-flight GetOrAdd.

Bodu.Collections.Specialized

Bit set

Growable packed bit set (Java BitSet shape) with NextSetBit / NextClearBit, in-place logical ops, and a non-boxing enumerator over set-bit indices.

Bodu.Collections.Probabilistic

Probabilistic collections (sketches)

Approximate sketches in fixed memory - BloomFilter<T> (membership, no false negatives), CountMinSketch<T> (frequencies, never underestimates), and HyperLogLog<T> (distinct counts, ~1.04/√m standard error), each with parameter-compatible merging and version-checked export/import.

Bodu.Collections.Generic.Graphs

Graphs and graph algorithms

Directed and undirected Graph<T> with optional edge weights; GraphAlgorithms for BFS/DFS, shortest path, topological sort, and connected components; plus DisjointSet<T> union-find.

Bodu.Collections.Generic.Trees

Tries and text search

The Trie string set and Trie<TValue> map with prefix queries (autocomplete-style), the path-compressed RadixTrie pair with the same surface, and the AhoCorasickAutomaton pair for single-pass multi-pattern text search.

N-ary tree

Mutable Tree<T> nodes with parent / ordered-children structure, stack-safe pre-, post-, and level-order traversals, descendants, ancestors, and leaves, and the attach / detach rules.

Bodu.Threading

Async coordination primitives

AsyncLock, AsyncSemaphore, AsyncReaderWriterLock, the async reset/countdown events, AsyncLazy<T>, AsyncDebouncer, and the RateGate rate limiter - the async-friendly peers of the BCL synchronization types.

Bodu.Functional

Memoization

Memoizer wraps a pure function in a thread-safe caching delegate - single- and multi-argument, with an optional key comparer.

Options, results, and eithers

Option<T>, Result<T>, and Either<TLeft,TRight> - allocation-free railway primitives with Map/Bind/Match combinators and async companions.

Bodu.Buffers

Pooled buffer builder

ArrayPool<T>-backed accumulation into a single contiguous result - implements IBufferWriter<T> for span-based writers.

Bodu (root namespace)

WeekPattern

Immutable bitmask value type for sets of days of the week; supports composition (MTuW), bitwise operators, parsing, and enumeration.

Bodu.Extensions

String extensions

The 77-method StringExtensions surface by task - substring by marker, wrapping, whitespace and lines, ordinal predicates, null coalescing, affixes, filtering, identifier casing with WordCasingOptions, slugs, safe file names, truncation.

Date and time extensions

DateTimeExtensions / DateOnlyExtensions - boundaries, day-of-week navigation, ISO and culture weeks, quarters and fiscal years, predicates, age and truncation, conversions - with the culture / working-week / quarter / provider overload matrix.

Fiscal quarters, working weeks, and weekend providers

CalendarQuarterDefinition, implementing IQuarterDefinitionProvider, the 52/53-week FiscalWeekQuarterProvider and FiscalWeekPattern, WeekOrdinal, a Friday-Saturday IWeekendDefinitionProvider, and the WorkingDaysOfWeek ↔ WeekPattern bridge.

Numeric, enum, array, span, and stream extensions

NumericExtensions, ComparableExtensions / ComparableHelper, EnumExtensions / Enums, ArrayExtensions, SpanExtensions, StreamExtensions, and BufferConverter.

Natural string comparer

NaturalStringComparer - ordering strings with embedded numbers the way a person would (file2 before file10).

Bodu.Collections.Generic.Extensions, Bodu.Sequences

Sequence operators and generators

The IEnumerableExtensions catalogue (lazy versus buffering, BatchPooled's lifetime rule, RecursiveSelectControl), the list and dictionary helpers, ShuffleHelpers versus Randomize, and SequenceGenerator.

Where to go next