Table of Contents

Class Bucketizer<TElement, TValue>

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

Splits collections into multiple buckets based on value-mapping. Create with Bucketize<TElement, TValue>(IEnumerable<TElement>, Func<TElement, TValue>).

public class Bucketizer<TElement, TValue>

Type Parameters

TElement

The common base type of all objects to be bucketized.

TValue

The type of the values to be matched.

Inheritance
object
Bucketizer<TElement, TValue>
Extension Methods

Constructors

Bucketizer(IEnumerable<TElement>, Func<TElement, TValue>)

Splits collections into multiple buckets based on value-mapping. Create with Bucketize<TElement, TValue>(IEnumerable<TElement>, Func<TElement, TValue>).

public Bucketizer(IEnumerable<TElement> elements, Func<TElement, TValue> valueRetriever)

Parameters

elements IEnumerable<TElement>

The elements to be bucketized.

valueRetriever Func<TElement, TValue>

A function to map elements to their according values used for bucketization.

Methods

Add(TValue, ICollection<TElement>)

Adds a new bucket rule.

public Bucketizer<TElement, TValue> Add(TValue value, ICollection<TElement> bucket)

Parameters

value TValue

A value to compare with the result of the value retriever using object.Equals(object, object).

bucket ICollection<TElement>

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

Returns

Bucketizer<TElement, TValue>

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

GetEnumerator()

Returns an enumerator that iterates through the collection.

public IEnumerator<BucketRule<TElement, TValue>> GetEnumerator()

Returns

IEnumerator<BucketRule<TElement, TValue>>

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

Run()

Adds each element to the first bucket with a matching value (if any). Set up with Add(TValue, ICollection<TElement>) first.

public void Run()