Browse Source

Moving SingleLinkedNode to a separate file.

Bart De Smet 8 years ago
parent
commit
98c1791a5a

+ 0 - 46
Ix.NET/Source/System.Linq.Async/System/Linq/Operators/AppendPrepend.cs

@@ -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 readonly SingleLinkedNode<TSource> prepended;

+ 55 - 0
Ix.NET/Source/System.Linq.Async/System/Linq/Operators/SingleLinkedNode.cs

@@ -0,0 +1,55 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the Apache 2.0 License.
+// See the LICENSE file in the project root for more information. 
+
+using System.Collections.Generic;
+using System.Diagnostics;
+
+namespace System.Linq
+{
+    internal 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();
+        }
+    }
+}