|
@@ -269,52 +269,6 @@ namespace System.Linq
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- private sealed class SingleLinkedNode<TSource>
|
|
|
|
|
- {
|
|
|
|
|
- public SingleLinkedNode(TSource first, TSource second)
|
|
|
|
|
- {
|
|
|
|
|
- Linked = new SingleLinkedNode<TSource>(first);
|
|
|
|
|
- Item = second;
|
|
|
|
|
- Count = 2;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- public SingleLinkedNode(TSource item)
|
|
|
|
|
- {
|
|
|
|
|
- Item = item;
|
|
|
|
|
- Count = 1;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- private SingleLinkedNode(SingleLinkedNode<TSource> linked, TSource item)
|
|
|
|
|
- {
|
|
|
|
|
- Debug.Assert(linked != null);
|
|
|
|
|
- Linked = linked;
|
|
|
|
|
- Item = item;
|
|
|
|
|
- Count = linked.Count + 1;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- public TSource Item { get; }
|
|
|
|
|
-
|
|
|
|
|
- public SingleLinkedNode<TSource> Linked { get; }
|
|
|
|
|
-
|
|
|
|
|
- public int Count { get; }
|
|
|
|
|
-
|
|
|
|
|
- public SingleLinkedNode<TSource> Add(TSource item) => new SingleLinkedNode<TSource>(this, item);
|
|
|
|
|
-
|
|
|
|
|
- public IEnumerator<TSource> GetEnumerator()
|
|
|
|
|
- {
|
|
|
|
|
- var array = new TSource[Count];
|
|
|
|
|
- var index = Count;
|
|
|
|
|
- for (var n = this; n != null; n = n.Linked)
|
|
|
|
|
- {
|
|
|
|
|
- --index;
|
|
|
|
|
- array[index] = n.Item;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- Debug.Assert(index == 0);
|
|
|
|
|
- return ((IEnumerable<TSource>)array).GetEnumerator();
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
private sealed class AppendPrependNAsyncIterator<TSource> : AppendPrependAsyncIterator<TSource>
|
|
private sealed class AppendPrependNAsyncIterator<TSource> : AppendPrependAsyncIterator<TSource>
|
|
|
{
|
|
{
|
|
|
private readonly SingleLinkedNode<TSource> prepended;
|
|
private readonly SingleLinkedNode<TSource> prepended;
|