Skip to content

Commit

Permalink
Use generic math in FirstIsToTheLeftOfSecond and `FirstIsToTheRight…
Browse files Browse the repository at this point in the history
…OfSecond`
  • Loading branch information
FreePhoenix888 committed Jan 7, 2023
1 parent 987295f commit 5b9d659
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,8 @@ public void Free(TElement node)

public bool IsEmpty(TElement node) => EqualityComparer<TreeElement>.Default.Equals(GetElement(node), default);

protected override bool FirstIsToTheLeftOfSecond(TElement first, TElement second) => Comparer.Compare(first, second) < 0;

protected override bool FirstIsToTheRightOfSecond(TElement first, TElement second) => Comparer.Compare(first, second) > 0;
protected override bool FirstIsToTheLeftOfSecond(TElement first, TElement second) => first < second;
protected override bool FirstIsToTheRightOfSecond(TElement first, TElement second) => first > second;

protected override ref TElement GetLeftReference(TElement node) => ref GetElement(node).Left;

Expand Down
4 changes: 2 additions & 2 deletions csharp/Platform.Collections.Methods.Tests/SizeBalancedTree.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,9 @@ public void Free(TElement node)

public bool IsEmpty(TElement node) => EqualityComparer<TreeElement>.Default.Equals(GetElement(node), default);

protected override bool FirstIsToTheLeftOfSecond(TElement first, TElement second) => Comparer.Compare(first, second) < 0;
protected override bool FirstIsToTheLeftOfSecond(TElement first, TElement second) => first < second;

protected override bool FirstIsToTheRightOfSecond(TElement first, TElement second) => Comparer.Compare(first, second) > 0;
protected override bool FirstIsToTheRightOfSecond(TElement first, TElement second) => first > second;

protected override ref TElement GetLeftReference(TElement node) => ref GetElement(node).Left;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,9 @@ public void Free(TElement node)

public bool IsEmpty(TElement node) => EqualityComparer<TreeElement>.Default.Equals(GetElement(node), default);

protected override bool FirstIsToTheLeftOfSecond(TElement first, TElement second) => Comparer.Compare(first, second) < 0;
protected override bool FirstIsToTheLeftOfSecond(TElement first, TElement second) => first < second;

protected override bool FirstIsToTheRightOfSecond(TElement first, TElement second) => Comparer.Compare(first, second) > 0;
protected override bool FirstIsToTheRightOfSecond(TElement first, TElement second) => first > second;

protected override sbyte GetBalance(TElement node) => GetElement(node).Balance;

Expand Down

0 comments on commit 5b9d659

Please sign in to comment.