Class SetOrderEnumerator<T>
A class that enumerates a collection into a given order of mutually exclusive sets
Inheritance
Implements
Inherited Members
Namespace: LemonEdge.Utils
Assembly: Utils.dll
Syntax
public class SetOrderEnumerator<T> : IEnumerable<T>, IEnumerable, IEnumerator<T>, IEnumerator, IDisposable
Type Parameters
Name | Description |
---|---|
T | The type of items being enumerated |
Remarks
The sets are definied as an ordered collection of functions that return if an item of type T
belongs in the set or not.
As such an item must belong to one, and only one, set - these must be mutually exclusive sets
For example:
public IEnumerable<int> GetMyInts()
{
var myItems = new List<int>() { 1, 2, 3, 4, 5, 6, 7, 8 };
var mySets = new List<Func<int, bool>>()
{
(int i) => i % 2 != 0, //odd
(int i) => i % 2 == 0 //even
};
return new SetOrderEnumerator<int>(myItems, mySets);
}
Will return:
1,3,5,7,2,4,6,8
Constructors
SetOrderEnumerator(IEnumerable<T>, IEnumerable<Func<T, Boolean>>)
Constructs a new SetOrderEnumerator<T> that can enumerate the given collections into ordered sets
Declaration
public SetOrderEnumerator(IEnumerable<T> items, IEnumerable<Func<T, bool>> sets)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.IEnumerable<T> | items | The items to be enumerated |
System.Collections.Generic.IEnumerable<System.Func<T, System.Boolean>> | sets | An ordered collection of functions defining if an item of type |
Properties
Current
System.Collections.Generic.IEnumerator<T>.Current Implementation. Returns current item in enumeration
Declaration
public T Current { get; }
Property Value
Type | Description |
---|---|
T |
Methods
Dispose()
Declaration
public void Dispose()
Dispose(Boolean)
Declaration
protected virtual void Dispose(bool disposing)
Parameters
Type | Name | Description |
---|---|---|
System.Boolean | disposing |
GetEnumerator()
System.Collections.Generic.IEnumerable<T>.GetEnumerator() Implementation
Declaration
public IEnumerator<T> GetEnumerator()
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerator<T> | An System.Collections.Generic.IEnumerator<T> |
GetMyInts()
Declaration
public IEnumerable<int> GetMyInts()
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<System.Int32> |
MoveNext()
System.Collections.IEnumerator.MoveNext() Implementation. Moves to next item in the enumeration
Declaration
public bool MoveNext()
Returns
Type | Description |
---|---|
System.Boolean |
Reset()
System.Collections.IEnumerator.Reset() Implementation. Resets the current enumeration
Declaration
public void Reset()
Explicit Interface Implementations
IEnumerable.GetEnumerator()
System.Collections.IEnumerable.GetEnumerator() Implementation
Declaration
IEnumerator IEnumerable.GetEnumerator()
Returns
Type | Description |
---|---|
System.Collections.IEnumerator | An System.Collections.IEnumerator |
IEnumerator.Current
System.Collections.IEnumerator.Current Implementation. The current item in the enumeration of type T
Declaration
object IEnumerator.Current { get; }
Returns
Type | Description |
---|---|
System.Object |