Table of Contents

Class Bucketizer<T>

Namespace
NanoByte.Common.Dispatch
Assembly
NanoByte.Common.dll

Splits collections into multiple buckets based on predicate matching. The first matching predicate wins. Create with Bucketize<T>(IEnumerable<T>).

public class Bucketizer<T>

Type Parameters

T

The common base type of all objects to be bucketized.

Inheritance
object
Bucketizer<T>
Extension Methods

Constructors

Bucketizer(IEnumerable<T>)

Splits collections into multiple buckets based on predicate matching. The first matching predicate wins. Create with Bucketize<T>(IEnumerable<T>).

public Bucketizer(IEnumerable<T> elements)

Parameters

elements IEnumerable<T>

The elements to be bucketized.

Methods

Add(Predicate<T>, ICollection<T>)

Adds a new bucket rule.

public Bucketizer<T> Add(Predicate<T> predicate, ICollection<T> bucket)

Parameters

predicate Predicate<T>

A condition to check elements against.

bucket ICollection<T>

The collection elements are added to if they match the predicate.

Returns

Bucketizer<T>

The "this" pointer for use in a "Fluent API" style.

GetEnumerator()

Returns an enumerator that iterates through the collection.

public IEnumerator<BucketRule<T>> GetEnumerator()

Returns

IEnumerator<BucketRule<T>>

An enumerator that can be used to iterate through the collection.

Run()

Adds each element to the first bucket with a matching predicate (if any). Set up with Add(Predicate<T>, ICollection<T>) first.

public void Run()