/// <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; } }
/// <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); }
/// <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;
/// <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));
/// <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));
/// <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);
/// <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);
/// <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));
/// <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;
#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;
/// <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)
/// <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 _);
/// <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));
/// <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 _)); }
/// <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;
/// <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;
/// <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;
/// <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;
/// <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));
/// <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;
/// <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));
/// <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));
/// <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)
/// <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);