Class Bucketizer<T>
Splits collections into multiple buckets based on predicate matching. The first matching predicate wins. Create with Bucketize<T>(IEnumerable<T>).
Namespace: NanoByte.Common.Dispatch
Assembly: NanoByte.Common.dll
Syntax
public class Bucketizer<T> : Object
Type Parameters
Name | Description |
---|---|
T | The common base type of all objects to be bucketized. |
Constructors
Bucketizer(IEnumerable<T>)
Splits collections into multiple buckets based on predicate matching. The first matching predicate wins. Create with Bucketize<T>(IEnumerable<T>).
Declaration
public Bucketizer(IEnumerable<T> elements)
Parameters
Type | Name | Description |
---|---|---|
IEnumerable<T> | elements | The elements to be bucketized. |
Methods
Add(Predicate<T>, ICollection<T>)
Adds a new bucket rule.
Declaration
public Bucketizer<T> Add(Predicate<T> predicate, ICollection<T> bucket)
Parameters
Type | Name | Description |
---|---|---|
Predicate<T> | predicate | A condition to check elements against. |
ICollection<T> | bucket | The collection elements are added to if they match the |
Returns
Type | Description |
---|---|
Bucketizer<T> | The "this" pointer for use in a "Fluent API" style. |
GetEnumerator()
Declaration
public IEnumerator<BucketRule<T>> GetEnumerator()
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerator<BucketRule<T>> |
Run()
Adds each element to the first bucket with a matching predicate (if any). Set up with Add(Predicate<T>, ICollection<T>) first.
Declaration
public void Run()