Skip to main content

IColligoEnumerable<T> API reference

IColligoEnumerable<T> is the core record type in Colligo.pas. All intermediate operators return a new IColligoEnumerable<T>. Terminal operators materialise the results.

Construction

FactoryDescription
TColligoArray<T>.From(AArray: TArray<T>)Wrap a typed dynamic array
TColligoArray.From<T>(AArray: array of T)Wrap an open array
TColligoList<T>.From(AList: TList<T>)Wrap a TList
TColligoList<T>.From(AArray: TArray<T>)Wrap a TArray via list
IColligoEnumerable<T>.Create(AEnumerator, ...)Wrap any IColligoEnumerableBase<T>

Filtering operators

MethodSignatureDescription
Where(APredicate: TFunc<T, Boolean>): IColligoEnumerable<T>Keep matching elements
Distinct(): IColligoEnumerable<T>Remove duplicates (default comparer)
Distinct(AComparer: IEqualityComparer<T>): IColligoEnumerable<T>Remove duplicates (custom comparer)
DistinctBy<TKey>(AKeySelector: TFunc<T, TKey>): IColligoEnumerable<T>Deduplicate by key
OfType<TResult>(AIsType, AConverter): IColligoEnumerable<TResult>Filter by type and convert
Cast<TResult>(): IColligoEnumerable<TResult>Re-interpret element type
Exclude(ASecond: IColligoEnumerable<T>): IColligoEnumerable<T>Set difference
ExcludeBy<TKey>(ASecond, AKeySelector): IColligoEnumerable<T>Set difference by key
Intersect(ASecond: IColligoEnumerable<T>): IColligoEnumerable<T>Set intersection
IntersectBy<TKey>(ASecond, AKeySelector): IColligoEnumerable<T>Intersection by key

Projection operators

MethodSignatureDescription
Select<TResult>(ASelector: TFunc<T, TResult>): IColligoEnumerable<TResult>Map each element
Select<TResult>(ASelector: TFunc<T, Integer, TResult>)Map with index
SelectMany<TResult>(ASelector: TFunc<T, TArray<TResult>>): IColligoEnumerable<TResult>Flatten
SelectMany<TCollection, TResult>(ACollectionSelector, AResultSelector)Flatten + project
Append(AElement: T): IColligoEnumerable<T>Append single element
Prepend(AElement: T): IColligoEnumerable<T>Prepend single element
Reverse(): IColligoEnumerable<T>Reverse order
DefaultIfEmpty(): IColligoEnumerable<T>Default element if empty
DefaultIfEmpty(ADefaultValue: T): IColligoEnumerable<T>Custom default

Partitioning operators

MethodSignatureDescription
Take(ACount: Integer): IColligoEnumerable<T>First N elements
TakeWhile(APredicate: TFunc<T, Boolean>)Take while predicate holds
TakeWhile(APredicate: TFunc<T, Integer, Boolean>)Take while (with index)
TakeLast(ACount: Integer): IColligoEnumerable<T>Last N elements
Skip(ACount: Integer): IColligoEnumerable<T>Skip first N
SkipWhile(APredicate: TFunc<T, Boolean>)Skip while predicate holds
SkipWhile(APredicate: TFunc<T, Integer, Boolean>)Skip while (with index)
SkipLast(ACount: Integer): IColligoEnumerable<T>Skip last N
ElementAt(AIndex: Integer): TElement at index
ElementAtOrDefault(AIndex: Integer): TElement at index or default

Ordering operators

MethodSignatureDescription
OrderBy(AComparer: TFunc<T, T, Integer>)Sort ascending
OrderBy<TKey>(AKeySelector, AComparer)Sort ascending by key
OrderByDesc(AComparer: TFunc<T, T, Integer>)Sort descending
Order(): IColligoEnumerable<T>Sort by default comparer
Order(AComparer: IComparer<T>)Sort by custom comparer
OrderDescending(): IColligoEnumerable<T>Sort desc by default
OrderDescending(AComparer: IComparer<T>)Sort desc by custom
ThenBy<TKey>(AKeySelector: TFunc<T, TKey>)Secondary sort ascending
ThenByDescending<TKey>(AKeySelector: TFunc<T, TKey>)Secondary sort descending

Set operators

MethodDescription
Union(ASecond)Distinct elements from both
UnionBy<TKey>(ASecond, AKeySelector)Union by key
Intersect(ASecond)Elements in both
Concat(ASecond)Concatenate (no dedup)
Exclude(ASecond)Elements not in second
SequenceEqual(ASecond)True if identical sequences

Join operators

MethodDescription
Join<TInner, TKey, TResult>(AInner, AOuterKey, AInnerKey, AResultSelector)Inner join
GroupJoin<TInner, TKey, TResult>(AInner, AOuterKey, AInnerKey, AResultSelector)Left outer join
Zip<TSecond, TResult>(ASecond, AResultSelector)Element-by-element combine

Aggregation operators (terminal)

MethodReturnsDescription
CountIntegerTotal elements
Count(APredicate)IntegerMatching elements
LongCountInt64Total elements (long)
LongCount(APredicate)Int64Matching (long)
Sum(ASelector)numericSum of projected values
SumCurrency(ASelector)CurrencySum as Currency
SumInt32(ASelector)Int32Sum as Int32
Average(ASelector)numericAverage of projected values
MinTMinimum element
Min(ASelector)numericMinimum of projected values
MinBy<TKey>(AKeySelector, AComparer)TElement with min key
MaxTMaximum element
Max(ASelector)numericMaximum of projected values
MaxBy<TKey>(AKeySelector, AComparer)TElement with max key
AnyBooleanNon-empty
Any(APredicate)BooleanAny match
All(APredicate)BooleanAll match
Contains(AValue)BooleanContains value
Contains(AValue, AComparer)BooleanContains (custom comparer)
FirstTFirst element (raises if empty)
First(APredicate)TFirst matching (raises if none)
FirstOrDefaultTFirst or Default(T)
FirstOrDefault(APredicate)TFirst matching or Default(T)
LastTLast element
Last(APredicate)TLast matching
LastOrDefaultTLast or Default(T)
LastOrDefault(APredicate)TLast matching or Default(T)
SingleTExactly one element
Single(APredicate)TExactly one matching
SingleOrDefaultTZero or one element
SingleOrDefault(APredicate)TZero or one matching
Aggregate(AReducer)TFold without seed
Aggregate<TAcc>(ASeed, AAccumulator)TAccFold with seed
Aggregate<TAcc, TResult>(...)TResultFold + result selector
AggregateBy<TKey, TAcc>(...)TDictionary<TKey, TAcc>Per-group fold
CountBy<TKey>(AKeySelector)TDictionary<TKey, Integer>Count per group

Materialisation (terminal)

MethodReturnsDescription
ToArrayIFluentArray<T>Execute pipeline, return array
ToListIFluentList<T>Execute pipeline, return list
ToHashSetTHashSet<T>Execute pipeline, return hash set
ToDictionary<TKey, TValue>(...)TDictionary<TKey, TValue>Execute, return dictionary
ToLookup<TKey, TElement>(...)TDictionary<TKey, TList<TElement>>Execute, return lookup
TryGetNonEnumeratedCount(out ACount)BooleanCount without iterating (if source supports it)

Iteration

var LEnum: IFluentEnumerator<T>;
LEnum := MyEnumerable.GetEnumerator;
while LEnum.MoveNext do
Process(LEnum.Current);

Or use for … in directly on IColligoEnumerable<T>.