Beispiel #1
0
        public void CopyTo(T[] array, int arrayIndex)
        {
            if (array == null)
            {
                throw new ArgumentNullException(nameof(array));
            }

            if (array.GetLowerBound(0) != 0)
            {
                throw new ArgumentException("Non zero lower bound");
            }

            if (arrayIndex < 0)
            {
                throw new ArgumentOutOfRangeException();
            }

            if (array.Length - arrayIndex < Count)
            {
                throw new ArgumentException();
            }

            var items = TraversalStrategy.Traversal(Head);

            while (items.MoveNext())
            {
                array[arrayIndex++] = items.Current;
            }
        }
Beispiel #2
0
        public static string TraversalStrategyToString(TraversalStrategy strategy)
        {
            switch (strategy)
            {
            case TraversalStrategy.BreadthFirst:
                return("breadthfirst");

            case TraversalStrategy.DepthFirst:
                return("depthfirst");

            default:
                throw new InvalidOperationException($"TraversalStrategy {strategy} binding not found, this is a client bug");
            }
        }
Beispiel #3
0
 public IEnumerator <T> GetEnumerator()
 {
     return(TraversalStrategy.Traversal(Head));
 }