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); } }
private void HandleNext(OrderedSetNode <T> node) { if (node.next != null) { OnMove(node.next.value); HandleNext(node.next); } }
/// <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; }