Example #1
0
 /// <summary>Removes a value.</summary>
 /// <typeparam name="T">The type of value.</typeparam>
 /// <param name="tree">The tree to remove the value from.</param>
 /// <param name="compare">The compare delegate.</param>
 public static void Remove <T>(this ISortedBinaryTree <T> tree, CompareToKnownValue <T> compare)
 {
     if (!tree.TryRemove(compare, out Exception exception))
     {
         throw exception;
     }
 }
Example #2
0
 /// <summary>Gets a value.</summary>
 /// <typeparam name="T">The type of value.</typeparam>
 /// <param name="tree">The tree to get the value from.</param>
 /// <param name="compare">The compare delegate. This must match the compare that the Red-Black tree is sorted with.</param>
 /// <returns>The value.</returns>
 public static T Get <T>(this ISortedBinaryTree <T> tree, CompareToKnownValue <T> compare)
 {
     if (!tree.TryGet(compare, out T value, out Exception exception))
     {
         throw exception;
     }
     return(value);
 }
Example #3
0
 /// <summary>Gets a traversal stepper for the tree.</summary>
 /// <typeparam name="T">The generic type of this data structure.</typeparam>
 /// <param name="tree">The tree to traverse.</param>
 /// <returns>The stepper of the traversal.</returns>
 public static StepperRef <T> StepperRef <T>(this ISortedBinaryTree <T> tree) =>
 tree.Stepper;
Example #4
0
 /// <summary>Does an optimized step function (right to left) for sorted binary search trees.</summary>
 /// <typeparam name="T">The generic type of this data structure.</typeparam>
 /// <param name="tree">The tree to traverse.</param>
 /// <param name="minimum">The minimum step value.</param>
 /// <param name="maximum">The maximum step value.</param>
 /// <returns>The stepper of the traversal.</returns>
 public static StepperRef <T> StepperRefReverse <T, _Compare>(this ISortedBinaryTree <T, _Compare> tree, T minimum, T maximum) =>
 x => tree.StepperReverse(minimum, maximum, y => x(ref y));
Example #5
0
 /// <summary>Does an optimized step function (left to right) for sorted binary search trees.</summary>
 /// <typeparam name="T">The generic type of this data structure.</typeparam>
 /// <param name="tree">The tree to traverse.</param>
 /// <param name="minimum">The minimum step value.</param>
 /// <param name="maximum">The maximum step value.</param>
 /// <returns>The stepper of the traversal.</returns>
 public static Func <Func <T, StepStatus>, StepStatus> StepperBreak <T, _Compare>(this ISortedBinaryTree <T, _Compare> tree, T minimum, T maximum) =>
 x => tree.Stepper(minimum, maximum, y => x(y));
Example #6
0
 /// <summary>Does an optimized step function (right to left) for sorted binary search trees.</summary>
 /// <typeparam name="T">The generic type of this data structure.</typeparam>
 /// <param name="tree">The tree to traverse.</param>
 /// <param name="minimum">The minimum step value.</param>
 /// <param name="maximum">The maximum step value.</param>
 /// <returns>The stepper of the traversal.</returns>
 public static StepperBreak <T> StepperBreakReverse <T>(this ISortedBinaryTree <T> tree, T minimum, T maximum) => x => tree.StepperReverse(y => x(y), minimum, maximum);
Example #7
0
 /// <summary>Tries to get a value.</summary>
 /// <typeparam name="T">The type of value.</typeparam>
 /// <param name="tree">The tree to get the value from.</param>
 /// <param name="sift">The compare delegate. This must match the compare that the Red-Black tree is sorted with.</param>
 /// <param name="value">The value if it is found.</param>
 /// <returns>True if the value was found or false if not.</returns>
 public static bool TryGet <T>(this ISortedBinaryTree <T> tree, out T?value, Func <T, CompareResult> sift) =>
 tree.TryGet(out value, out _, sift);
Example #8
0
 /// <summary>Does an optimized step function (right to left) for sorted binary search trees.</summary>
 /// <typeparam name="T">The generic type of this data structure.</typeparam>
 /// <param name="tree">The tree to traverse.</param>
 /// <param name="minimum">The minimum step value.</param>
 /// <param name="maximum">The maximum step value.</param>
 /// <returns>The stepper of the traversal.</returns>
 public static Func <Func <T, StepStatus>, StepStatus> StepperBreakReverse <T>(this ISortedBinaryTree <T> tree, T minimum, T maximum) =>
 x => tree.StepperReverse(minimum, maximum, y => x(y));
Example #9
0
 /// <summary>Gets a reverse traversal stepper for the tree.</summary>
 /// <typeparam name="T">The generic type of this data structure.</typeparam>
 /// <param name="tree">The tree to traverse.</param>
 /// <returns>The stepper of the traversal.</returns>
 public static StepperRefBreak <T> StepperRefBreakReverse <T>(this ISortedBinaryTree <T> tree) =>
 tree.StepperReverse;
Example #10
0
#pragma warning restore CS1572 // XML comment has a param tag, but there is no parameter by that name
#pragma warning restore CS1711 // XML comment has a typeparam tag, but there is no type parameter by that name

        #endregion

        #region Extensions

        /// <summary>Gets a traversal stepper for the tree.</summary>
        /// <typeparam name="T">The generic type of this data structure.</typeparam>
        /// <param name="tree">The tree to traverse.</param>
        /// <returns>The stepper of the traversal.</returns>
        public static Action <Action <T> > Stepper <T, _Compare>(this ISortedBinaryTree <T, _Compare> tree) =>
        tree.Stepper;
Example #11
0
 /// <summary>Gets a value.</summary>
 /// <typeparam name="T">The type of value.</typeparam>
 /// <param name="tree">The tree to get the value from.</param>
 /// <param name="compare">The compare delegate. This must match the compare that the Red-Black tree is sorted with.</param>
 /// <returns>The value.</returns>
 public static T Get <T>(this ISortedBinaryTree <T> tree, CompareToKnownValue <T> compare) =>
 tree.TryGet(compare, out T value, out Exception exception)
Example #12
0
 /// <summary>Tries to get a value.</summary>
 /// <typeparam name="T">The type of value.</typeparam>
 /// <param name="tree">The tree to get the value from.</param>
 /// <param name="compare">The compare delegate. This must match the compare that the Red-Black tree is sorted with.</param>
 /// <param name="value">The value if it is found.</param>
 /// <returns>True if the value was found or false if not.</returns>
 public static bool TryGet <T>(this ISortedBinaryTree <T> tree, CompareToKnownValue <T> compare, out T value) =>
 tree.TryGet(compare, out value, out _);
Example #13
0
 /// <summary>Does an optimized step function (left to right) for sorted binary search trees.</summary>
 /// <typeparam name="T">The generic type of this data structure.</typeparam>
 /// <param name="tree">The tree to traverse.</param>
 /// <param name="minimum">The minimum step value.</param>
 /// <param name="maximum">The maximum step value.</param>
 /// <returns>The stepper of the traversal.</returns>
 public static StepperBreak <T> StepperBreak <T>(this ISortedBinaryTree <T> tree, T minimum, T maximum) =>
 x => tree.Stepper(minimum, maximum, y => x(y));
Example #14
0
 /// <summary>Tries to remove a value.</summary>
 /// <typeparam name="T">The type of value.</typeparam>
 /// <param name="tree">The tree to remove the value from.</param>
 /// <param name="compare">The compare delegate.</param>
 /// <returns>True if the remove was successful or false if not.</returns>
 public static bool TryRemove <T>(this ISortedBinaryTree <T> tree, CompareToKnownValue <T> compare)
 {
     return(tree.TryRemove(compare, out _));
 }
Example #15
0
 /// <summary>Gets a reverse traversal stepper for the tree.</summary>
 /// <typeparam name="T">The generic type of this data structure.</typeparam>
 /// <param name="tree">The tree to traverse.</param>
 /// <returns>The stepper of the traversal.</returns>
 public static Action <Action <T> > StepperReverse <T>(this ISortedBinaryTree <T> tree) =>
 tree.StepperReverse;
Example #16
0
 /// <summary>Gets a traversal stepper for the tree.</summary>
 /// <typeparam name="T">The generic type of this data structure.</typeparam>
 /// <param name="tree">The tree to traverse.</param>
 /// <returns>The stepper of the traversal.</returns>
 public static Func <Func <T, StepStatus>, StepStatus> StepperBreak <T, _Compare>(this ISortedBinaryTree <T, _Compare> tree) =>
 tree.Stepper;
Example #17
0
 /// <summary>Gets a reverse traversal stepper for the tree.</summary>
 /// <typeparam name="T">The generic type of this data structure.</typeparam>
 /// <param name="tree">The tree to traverse.</param>
 /// <returns>The stepper of the traversal.</returns>
 public static Func <Func <T, StepStatus>, StepStatus> StepperBreakReverse <T>(this ISortedBinaryTree <T> tree) =>
 tree.StepperReverse;
Example #18
0
 /// <summary>Gets a traversal stepper for the tree.</summary>
 /// <typeparam name="T">The generic type of this data structure.</typeparam>
 /// <param name="tree">The tree to traverse.</param>
 /// <returns>The stepper of the traversal.</returns>
 public static StepperRefBreak <T> StepperRefBreak <T, _Compare>(this ISortedBinaryTree <T, _Compare> tree) =>
 tree.Stepper;
Example #19
0
 /// <summary>Does an optimized step function (right to left) for sorted binary search trees.</summary>
 /// <typeparam name="T">The generic type of this data structure.</typeparam>
 /// <param name="tree">The tree to traverse.</param>
 /// <param name="minimum">The minimum step value.</param>
 /// <param name="maximum">The maximum step value.</param>
 /// <returns>The stepper of the traversal.</returns>
 public static Action <Action <T> > StepperReverse <T>(this ISortedBinaryTree <T> tree, T minimum, T maximum) =>
 x => tree.StepperReverse(minimum, maximum, y => x(y));
Example #20
0
 /// <summary>Gets a reverse traversal stepper for the tree.</summary>
 /// <typeparam name="T">The generic type of this data structure.</typeparam>
 /// <param name="tree">The tree to traverse.</param>
 /// <returns>The stepper of the traversal.</returns>
 public static StepperRef <T> StepperRefReverse <T, _Compare>(this ISortedBinaryTree <T, _Compare> tree) =>
 tree.StepperReverse;
Example #21
0
 /// <summary>Does an optimized step function (right to left) for sorted binary search trees.</summary>
 /// <typeparam name="T">The generic type of this data structure.</typeparam>
 /// <param name="tree">The tree to traverse.</param>
 /// <param name="minimum">The minimum step value.</param>
 /// <param name="maximum">The maximum step value.</param>
 /// <returns>The stepper of the traversal.</returns>
 public static StepperRefBreak <T> StepperRefBreakReverse <T>(this ISortedBinaryTree <T> tree, T minimum, T maximum) =>
 x => tree.StepperReverse(minimum, maximum, y => x(ref y));
Example #22
0
 /// <summary>Does an optimized step function (left to right) for sorted binary search trees.</summary>
 /// <typeparam name="T">The generic type of this data structure.</typeparam>
 /// <param name="tree">The tree to traverse.</param>
 /// <param name="minimum">The minimum step value.</param>
 /// <param name="maximum">The maximum step value.</param>
 /// <returns>The stepper of the traversal.</returns>
 public static Action <Action <T> > Stepper <T, _Compare>(this ISortedBinaryTree <T, _Compare> tree, T minimum, T maximum) =>
 x => tree.Stepper(minimum, maximum, y => x(y));
Example #23
0
 /// <summary>Gets a value.</summary>
 /// <typeparam name="T">The type of value.</typeparam>
 /// <param name="tree">The tree to get the value from.</param>
 /// <param name="sift">The compare delegate. This must match the compare that the Red-Black tree is sorted with.</param>
 /// <returns>The value.</returns>
 public static T?Get <T>(this ISortedBinaryTree <T> tree, Func <T, CompareResult> sift) =>
 tree.TryGet(out T value, out Exception? exception, sift)
Example #24
0
 /// <summary>Does an optimized step function (left to right) for sorted binary search trees.</summary>
 /// <typeparam name="T">The generic type of this data structure.</typeparam>
 /// <param name="tree">The tree to traverse.</param>
 /// <param name="minimum">The minimum step value.</param>
 /// <param name="maximum">The maximum step value.</param>
 /// <returns>The stepper of the traversal.</returns>
 public static StepperRef <T> StepperRef <T>(this ISortedBinaryTree <T> tree, T minimum, T maximum) => x => tree.Stepper(y => x(ref y), minimum, maximum);