Enhanced C#
Loyc library documentation
 All Classes Namespaces Functions Variables Enumerations Enumerator Properties Events Pages
List of all members
Loyc.Collections.IScannable< T > Interface Template Reference

A sequence of T objects that is meant to be read in chunks. This interface is essentially a faster version of IEnumerable{T}: it allows the caller to scan a sequence faster by avoiding unnecessary interface calls. More...


Source file:
Inheritance diagram for Loyc.Collections.IScannable< T >:
Loyc.Collections.IScan< T > Loyc.Collections.ArraySlice< T > Loyc.Collections.BufferedSequence< T > Loyc.Collections.Impl.InternalList< T > Loyc.Collections.ReadOnlyArraySlice< T > Loyc.Collections.ScannableEnumerable< T > Loyc.Collections.BufferedSequence< T >.Scanner Loyc.Collections.ScannableEnumerable< T >.Scanner< TEnumerator >

Remarks

A sequence of T objects that is meant to be read in chunks. This interface is essentially a faster version of IEnumerable{T}: it allows the caller to scan a sequence faster by avoiding unnecessary interface calls.

Example usage:

public static List<T> AddToList<T>(IScannable<T> sequence, List<T> list)
{
IScanner<T> scanner = sequence.Scan();
var current = ReadOnlySpan<T>.Empty;
var temp = Memory<T>.Empty;
while ((current = scanner.Read(current.Length, 0, ref temp).Span).Length != 0) {
for (int i = 0; i < current.Length; i++)
list.Add(current[i]);
}
return list;
}
]]>

In practice, an object that implements Scan() will also implement IEnumerable{T}, and this interface includes IEnumerable{T} for disambiguation purposes, so that

Additional Inherited Members

- Public Member Functions inherited from Loyc.Collections.IScan< T >
IScanner< T > Scan ()