Example #1
0
        private void RecalculateResult(OrderedSetNode <T> root)
        {
            if (root == null)
            {
                return;
            }

            int aToValue = min.CompareTo(root.value);
            int bToValue = max.CompareTo(root.value);

            if (aToValue < 0)
            {
                RecalculateResult(root.left);
            }

            if (aToValue <= 0 && bToValue >= 0)
            {
                OnMove(root.value);
                HandleNext(root);
            }

            if (bToValue > 0)
            {
                RecalculateResult(root.right);
            }
        }
Example #2
0
 private void HandleNext(OrderedSetNode <T> node)
 {
     if (node.next != null)
     {
         OnMove(node.next.value);
         HandleNext(node.next);
     }
 }
Example #3
0
        /// <summary>
        /// Triggers the calculations.
        /// </summary>
        /// <param name="root">The root node of the <c>OrderedSet</c>.</param>
        public void Calculate(OrderedSetNode <T> root)
        {
            if (calculated)
            {
                throw new Exception("RangeComparer cannot be used more then once.");
            }

            min = CreateMinBaundary();
            max = CreateMaxBaundary();

            RecalculateResult(root);
            calculated = true;
        }