Exemplo n.º 1
0
 /// <summary>Invokes a delegate for each entry in the data structure.</summary>
 /// <param name="step">The delegate to invoke on each item in the structure.</param>
 /// <returns>The resulting status of the iteration.</returns>
 public StepStatus Stepper(StepBreak <T> step)
 {
     for (Node node = _head; !(node is null); node = node.Next)
     {
         if (step(node.Value) is Break)
         {
             return(Break);
         }
     }
     return(Continue);
 }
Exemplo n.º 2
0
 /// <summary>Invokes a delegate for each entry in the data structure.</summary>
 /// <param name="step">The delegate to invoke on each item in the structure.</param>
 /// <returns>The resulting status of the iteration.</returns>
 public StepStatus Stepper(StepBreak <T> step)
 {
     for (Node current = _head; !(current is null); current = current.Next)
     {
         if (step(current.Value) is Break)
         {
             return(Break);
         }
     }
     return(Continue);
 }
Exemplo n.º 3
0
 /// <summary>Invokes a delegate for each entry in the data structure.</summary>
 /// <param name="step_function">The delegate to invoke on each item in the structure.</param>
 /// <returns>The resulting status of the iteration.</returns>
 public StepStatus Stepper(StepBreak <T> step_function)
 {
     for (int i = 0; i < this._count; i++)
     {
         if (step_function(this._list[i]) == StepStatus.Break)
         {
             return(StepStatus.Break);
         }
     }
     return(StepStatus.Continue);
 }
Exemplo n.º 4
0
 /// <summary>Invokes a delegate for each entry in the data structure.</summary>
 /// <param name="function">The delegate to invoke on each item in the structure.</param>
 /// <returns>The resulting status of the iteration.</returns>
 public StepStatus Stepper(StepBreak <T> function)
 {
     for (Node looper = _head; looper != null; looper = looper.Next)
     {
         if (function(looper.Value) == Break)
         {
             return(Break);
         }
     }
     return(Continue);
 }
Exemplo n.º 5
0
 /// <summary>Invokes a delegate for each entry in the data structure.</summary>
 /// <param name="step_function">The delegate to invoke on each item in the structure.</param>
 /// <returns>The resulting status of the iteration.</returns>
 public StepStatus Stepper(StepBreak <T> step)
 {
     for (int i = 0; i < _count; i++)
     {
         if (step(_queue[i]) == StepStatus.Break)
         {
             return(StepStatus.Break);
         }
     }
     return(StepStatus.Continue);
 }
Exemplo n.º 6
0
 /// <summary>Invokes a delegate for each entry in the data structure.</summary>
 /// <param name="function">The delegate to invoke on each item in the structure.</param>
 /// <returns>The resulting status of the iteration.</returns>
 public StepStatus Stepper(StepBreak <T> function)
 {
     for (int i = 0; i < _array.Length; i++)
     {
         if (function(_array[i]) == StepStatus.Break)
         {
             return(StepStatus.Break);
         }
     }
     return(StepStatus.Continue);
 }
Exemplo n.º 7
0
 /// <summary>Invokes a delegate for each entry in the data structure.</summary>
 /// <param name="step">The delegate to invoke on each item in the structure.</param>
 /// <returns>The resulting status of the iteration.</returns>
 public StepStatus Stepper(StepBreak <T> step)
 {
     for (Node looper = _top; looper != null; looper = looper.Down)
     {
         if (step(looper.Value) == Break)
         {
             return(Break);
         }
     }
     return(Continue);
 }
Exemplo n.º 8
0
Arquivo: Set.cs Projeto: Thaina/Towel
 /// <summary>Steps through all the values of the set.</summary>
 /// <param name="step">The action to perform on every value in the set.</param>
 /// <returns>The status of the stepper.</returns>
 /// <runtime>Θ(n * step)</runtime>
 public StepStatus Stepper(StepBreak <T> step)
 {
     for (int i = 0; i < _table.Length; i++)
     {
         for (Node node = _table[i]; node != null; node = node.Next)
         {
             if (step(node.Value) == Break)
             {
                 return(Break);
             }
         }
     }
     return(Continue);
 }
Exemplo n.º 9
0
Arquivo: Set.cs Projeto: Thaina/Towel
 /// <summary>Steps through all the values of the set.</summary>
 /// <param name="step">The action to perform on every value in the set.</param>
 /// <returns>The status of the stepper.</returns>
 /// <runtime>Θ(n * step)</runtime>
 public StepStatus Stepper(StepBreak <T> step)
 {
     for (int i = 0; i < _table.Length; i++)
     {
         if (!(_table[i] is null))
         {
             if (_table[i].Stepper(step) == Break)
             {
                 return(Break);
             }
         }
     }
     return(Continue);
 }
Exemplo n.º 10
0
 /// <summary>Invokes a delegate for each entry in the data structure.</summary>
 /// <param name="step">The delegate to invoke on each item in the structure.</param>
 /// <returns>The resulting status of the iteration.</returns>
 public StepStatus Stepper(StepBreak <T> step)
 {
     for (int i = 0; i < _elements.Length; i++)
     {
         T[] array       = _elements[i];
         int arrayLength = array.Length;
         for (int j = 0; j < arrayLength; j++)
         {
             if (step(array[i]) == StepStatus.Break)
             {
                 return(StepStatus.Break);
             }
         }
     }
     return(StepStatus.Continue);
 }
Exemplo n.º 11
0
        /// <summary>Invokes a delegate for each entry in the data structure.</summary>
        /// <param name="step">The delegate to invoke on each item in the structure.</param>
        /// <returns>The resulting status of the iteration.</returns>
        public StepStatus Pairs(StepBreak <T, K> step)
        {
            int num = 0;

            for (int index = 0; index < _lastIndex && num < _count; ++index)
            {
                if (_nodes[index].Hash >= 0)
                {
                    ++num;
                    if (step(_nodes[index].Value, _nodes[index].Key) == StepStatus.Break)
                    {
                        return(StepStatus.Break);
                    }
                }
            }
            return(StepStatus.Continue);
        }
Exemplo n.º 12
0
        /// <summary>Invokes a delegate for each entry in the data structure.</summary>
        /// <param name="step">The delegate to invoke on each item in the structure.</param>
        /// <returns>The resulting status of the iteration.</returns>
        /// <runtime>O(n * step)</runtime>
        public StepStatus StepperReverse(StepBreak <T> step)
        {
            StepStatus StepperReverse(Node NODE)
            {
                if (NODE != null && NODE != _sentinelNode)
                {
                    return
                        (StepperReverse(NODE.RightChild) == Break ? Break :
                         step(NODE.Value) == Break ? Break :
                         StepperReverse(NODE.LeftChild) == Break ? Break :
                         Continue);
                }
                return(Continue);
            }

            return(StepperReverse(_root));
        }
Exemplo n.º 13
0
        /// <summary>Invokes a delegate for each entry in the data structure.</summary>
        /// <param name="step">The delegate to invoke on each item in the structure.</param>
        /// <returns>The resulting status of the iteration.</returns>
        /// <runtime>O(n * step)</runtime>
        public StepStatus StepperReverse(StepBreak <T> step)
        {
            StepStatus StepperReverse(Node node)
            {
                if (node != null)
                {
                    return
                        (StepperReverse(node.RightChild) == Break ? Break :
                         step(node.Value) == Break ? Break :
                         StepperReverse(node.LeftChild) == Break ? Break :
                         Continue);
                }
                return(Continue);
            }

            return(StepperReverse(_root));
        }
Exemplo n.º 14
0
        /// <summary>Invokes a delegate for each entry in the data structure.</summary>
        /// <param name="step">The delegate to invoke on each item in the structure.</param>
        /// <returns>The resulting status of the iteration.</returns>
        /// <runtime>O(n * step)</runtime>
        public StepStatus Stepper(StepBreak <T> step)
        {
            StepStatus Stepper(Node node)
            {
                if (node != null && node != _sentinelNode)
                {
                    return
                        (Stepper(node.LeftChild) == Break ? Break :
                         step(node.Value) == Break ? Break :
                         Stepper(node.RightChild) == Break ? Break :
                         Continue);
                }
                return(Continue);
            }

            return(Stepper(_root));
        }
Exemplo n.º 15
0
        /// <summary>Invokes a delegate for each entry in the data structure.</summary>
        /// <param name="step_function">The delegate to invoke on each item in the structure.</param>
        /// <returns>The resulting status of the iteration.</returns>
        public StepStatus Stepper(StepBreak <T> step_function)
        {
            for (int i = 0; i < this._stack.Length; i++)
            {
                switch (step_function(this._stack[i]))
                {
                case StepStatus.Break:
                    return(StepStatus.Break);

                case StepStatus.Continue:
                    continue;

                default:
                    throw new System.NotImplementedException();
                }
            }
            return(StepStatus.Continue);
        }
Exemplo n.º 16
0
        internal StepStatus StepperReverse(StepBreak <T> step_delegate, Node node)
        {
            if (node == null)
            {
                return(Continue);
            }
            switch (Stepper(step_delegate, node.Children[node.ItemCount]))
            {
            case Break:
                return(Break);

            case Continue:
                break;

            default:
                throw new System.NotImplementedException();
            }
            for (int i = node.ItemCount - 1; i > -1; i--)
            {
                switch (step_delegate(node.Items[i]))
                {
                case Break:
                    return(Break);

                case Continue:
                    break;

                default:
                    throw new System.NotImplementedException();
                }
                switch (Stepper(step_delegate, node.Children[i]))
                {
                case Break:
                    return(Break);

                case Continue:
                    break;

                default:
                    throw new System.NotImplementedException();
                }
            }
            return(Continue);
        }
Exemplo n.º 17
0
        /// <summary>Steps through all the pairs.</summary>
        /// <param name="step">The step function.</param>
        public StepStatus Pairs(StepBreak <T, K> step)
        {
            Node node;

            for (int i = 0; i < _table.Length; i++)
            {
                if ((node = _table[i]) != null)
                {
                    do
                    {
                        if (step(node.Value, node.Key) == StepStatus.Break)
                        {
                            return(StepStatus.Break);
                        }
                    } while ((node = node.Next) != null);
                }
            }
            return(StepStatus.Continue);
        }
Exemplo n.º 18
0
 private StepStatus StepperInOrder(StepBreak <T> function, Node node)
 {
     if (node != null && node.LeftChild != null && node.RightChild != null)
     {
         if (StepperInOrder(function, node.LeftChild) == StepStatus.Break)
         {
             return(StepStatus.Break);
         }
         if (function(node.Value) == StepStatus.Break)
         {
             return(StepStatus.Break);
         }
         if (StepperInOrder(function, node.RightChild) == StepStatus.Break)
         {
             return(StepStatus.Break);
         }
     }
     return(StepStatus.Continue);
 }
Exemplo n.º 19
0
        /// <summary>Invokes a delegate for each entry in the data structure.</summary>
        /// <param name="function">The delegate to invoke on each item in the structure.</param>
        /// <returns>The resulting status of the iteration.</returns>
        public StepStatus Stepper(StepBreak <T> function)
        {
            Node node;

            for (int i = 0; i < _table.Length; i++)
            {
                if ((node = _table[i]) != null)
                {
                    do
                    {
                        if (function(node.Value) == StepStatus.Break)
                        {
                            return(StepStatus.Break);
                        }
                    } while ((node = node.Next) != null);
                }
            }
            return(StepStatus.Continue);
        }
Exemplo n.º 20
0
        /// <summary>Invokes a delegate for each entry in the data structure.</summary>
        /// <param name="function">The delegate to invoke on each item in the structure.</param>
        /// <returns>The resulting status of the iteration.</returns>
        public StepStatus Stepper(StepBreak <T> function)
        {
            for (int i = 0; i < this._table.Length; i++)
            {
                if (object.ReferenceEquals(null, this._table[i]))
                {
                    switch (this._table[i].Stepper(function))
                    {
                    case StepStatus.Break:
                        return(StepStatus.Break);

                    case StepStatus.Continue:
                        continue;

                    default:
                        throw new System.NotImplementedException();
                    }
                }
            }
            return(StepStatus.Continue);
        }
Exemplo n.º 21
0
        /// <summary>Invokes a delegate for each entry in the data structure.</summary>
        /// <param name="step_function">The delegate to invoke on each item in the structure.</param>
        /// <param name="minimum">The minimum value of the optimized stepper function.</param>
        /// <param name="maximum">The maximum value of the optimized stepper function.</param>
        /// <remarks>Runtime: O(n * traversalFunction).</remarks>
        public virtual StepStatus StepperReverse(StepBreak <T> step_function, T minimum, T maximum)
        {
            StepStatus StepperReverse(StepBreak <T> STEP, Node NODE, T MINIMUM, T MAXIMUM)
            {
                if (NODE != null)
                {
                    if (_compare(NODE.Value, MINIMUM) == Comparison.Less)
                    {
                        return(StepperReverse(STEP, NODE.RightChild, MINIMUM, MAXIMUM));
                    }
                    else if (_compare(NODE.Value, MAXIMUM) == Comparison.Greater)
                    {
                        return(StepperReverse(STEP, NODE.LeftChild, MINIMUM, MAXIMUM));
                    }
                    else
                    {
                        if (StepperReverse(STEP, NODE.RightChild, MINIMUM, MAXIMUM) == StepStatus.Break)
                        {
                            return(StepStatus.Break);
                        }
                        if (STEP(NODE.Value) == StepStatus.Break)
                        {
                            return(StepStatus.Break);
                        }
                        if (StepperReverse(STEP, NODE.LeftChild, MINIMUM, MAXIMUM) == StepStatus.Break)
                        {
                            return(StepStatus.Break);
                        }
                    }
                }
                return(StepStatus.Continue);
            }

            if (_compare(minimum, maximum) == Comparison.Greater)
            {
                throw new InvalidOperationException("!(" + nameof(minimum) + " <= " + nameof(maximum) + ")");
            }
            return(StepperReverse(step_function, _root, minimum, maximum));
        }
Exemplo n.º 22
0
        /// <summary>Invokes a delegate for each entry in the data structure.</summary>
        /// <param name="function">The delegate to invoke on each item in the structure.</param>
        /// <returns>The resulting status of the iteration.</returns>
        public StepStatus Stepper(StepBreak <T> function)
        {
            Node current = this._head;

            while (current != null)
            {
                switch (function(current.Value))
                {
                case StepStatus.Break:
                    current = current.Next;
                    return(StepStatus.Break);

                case StepStatus.Continue:
                    current = current.Next;
                    continue;

                default:
                    current = current.Next;
                    throw new System.NotImplementedException();
                }
            }
            return(StepStatus.Continue);
        }
Exemplo n.º 23
0
        /// <summary>Invokes a delegate for each entry in the data structure.</summary>
        /// <param name="step">The delegate to invoke on each item in the structure.</param>
        /// <returns>The resulting status of the iteration.</returns>
        public StepStatus Pairs(StepBreak <Link <T, K> > step)
        {
            int num = 0;

            for (int index = 0; index < this._lastIndex && num < _count; ++index)
            {
                if (_nodes[index].Hash >= 0)
                {
                    ++num;
                    switch (step(new Link <T, K>(_nodes[index].Value, _nodes[index].Key)))
                    {
                    case StepStatus.Break:
                        return(StepStatus.Break);

                    case StepStatus.Continue:
                        continue;

                    default:
                        throw new System.NotImplementedException();
                    }
                }
            }
            return(StepStatus.Continue);
        }
Exemplo n.º 24
0
        /// <summary>Invokes a delegate for each entry in the data structure.</summary>
        /// <param name="function">The delegate to invoke on each item in the structure.</param>
        /// <returns>The resulting status of the iteration.</returns>
        public StepStatus Stepper(StepBreak <T> function)
        {
            int num = 0;

            for (int index = 0; index < this._lastIndex && num < this._count; ++index)
            {
                if (this._nodes[index].Hash >= 0)
                {
                    ++num;
                    switch (function(this._nodes[index].Value))
                    {
                    case StepStatus.Break:
                        return(StepStatus.Break);

                    case StepStatus.Continue:
                        continue;

                    default:
                        throw new System.NotImplementedException();
                    }
                }
            }
            return(StepStatus.Continue);
        }
Exemplo n.º 25
0
        /// <summary>Steps through all the keys.</summary>
        /// <param name="step">The step function.</param>
        public StepStatus Keys(StepBreak <K> step)
        {
            int num = 0;

            for (int index = 0; index < _lastIndex && num < _count; ++index)
            {
                if (this._nodes[index].Hash >= 0)
                {
                    ++num;
                    switch (step(_nodes[index].Key))
                    {
                    case StepStatus.Break:
                        return(StepStatus.Break);

                    case StepStatus.Continue:
                        continue;

                    default:
                        throw new NotImplementedException();
                    }
                }
            }
            return(StepStatus.Continue);
        }
Exemplo n.º 26
0
        /// <summary>Invokes a delegate for each entry in the data structure.</summary>
        /// <param name="step">The delegate to invoke on each item in the structure.</param>
        /// <returns>The resulting status of the iteration.</returns>
        /// <remarks>Runtime: O(n * traversalFunction).</remarks>
        public StepStatus StepperReverse(StepBreak <T> step)
        {
            StepStatus StepperReverse(StepBreak <T> STEP, Node NODE)
            {
                if (NODE != null)
                {
                    if (StepperReverse(STEP, NODE.RightChild) == StepStatus.Break)
                    {
                        return(StepStatus.Break);
                    }
                    if (STEP(NODE.Value) == StepStatus.Break)
                    {
                        return(StepStatus.Break);
                    }
                    if (StepperReverse(STEP, NODE.LeftChild) == StepStatus.Break)
                    {
                        return(StepStatus.Break);
                    }
                }
                return(StepStatus.Continue);
            }

            return(StepperReverse(step, _root));
        }
Exemplo n.º 27
0
 public StepStatus Stepper(StepBreak <T, T> step)
 {
     throw new NotImplementedException();
 }
Exemplo n.º 28
0
 /// <summary>Steps through all the edges in the graph.</summary>
 /// <param name="step">The action to perform on all the edges in the graph.</param>
 /// <returns>The status of the stepper operation.</returns>
 public StepStatus Stepper(StepBreak <T, T> step) => _edges.Stepper(edge => step(edge.Start, edge.End));
Exemplo n.º 29
0
 /// <summary>Invokes a delegate for each entry in the data structure.</summary>
 /// <param name="function">The delegate to invoke on each item in the structure.</param>
 /// <returns>The resulting status of the iteration.</returns>
 public StepStatus Stepper(StepBreak <T> function)
 {
     throw new System.NotImplementedException();
 }
Exemplo n.º 30
0
 /// <summary>Steps through all the nodes in the graph.</summary>
 /// <param name="step">The action to perform on all the nodes in the graph.</param>
 /// <returns>The status of the stepper operation.</returns>
 public StepStatus Stepper(StepBreak <T> step) => _nodes.Stepper(step);