Skip to content

Commit d8a82b9

Browse files
committed
rename Order to SortDirection
1 parent d9bb857 commit d8a82b9

38 files changed

+101
-111
lines changed

src/Advanced.Algorithms/DataStructures/Heap/BHeap.cs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,30 +17,30 @@ public class BHeap<T> : IEnumerable<T> where T : IComparable
1717

1818
public int Count { get; private set; }
1919

20-
public BHeap(Order order = Order.Ascending)
21-
: this(order, null, null) { }
20+
public BHeap(SortDirection sortDirection = SortDirection.Ascending)
21+
: this(sortDirection, null, null) { }
2222

23-
public BHeap(Order order, IEnumerable<T> initial)
24-
: this(order, initial, null) { }
23+
public BHeap(SortDirection sortDirection, IEnumerable<T> initial)
24+
: this(sortDirection, initial, null) { }
2525

26-
public BHeap(Order order, IComparer<T> comparer)
27-
: this(order, null, comparer) { }
26+
public BHeap(SortDirection sortDirection, IComparer<T> comparer)
27+
: this(sortDirection, null, comparer) { }
2828

2929
/// <summary>
3030
/// Time complexity: O(n) if initial is provided. Otherwise O(1).
3131
/// </summary>
3232
/// <param name="initial">The initial items in the heap.</param>
33-
public BHeap(Order order, IEnumerable<T> initial, IComparer<T> comparer)
33+
public BHeap(SortDirection sortDirection, IEnumerable<T> initial, IComparer<T> comparer)
3434
{
35-
this.isMaxHeap = order == Order.Descending;
35+
this.isMaxHeap = sortDirection == SortDirection.Descending;
3636

3737
if (comparer != null)
3838
{
39-
this.comparer = new CustomComparer<T>(order, comparer);
39+
this.comparer = new CustomComparer<T>(sortDirection, comparer);
4040
}
4141
else
4242
{
43-
this.comparer = new CustomComparer<T>(order, Comparer<T>.Default);
43+
this.comparer = new CustomComparer<T>(sortDirection, Comparer<T>.Default);
4444
}
4545

4646
if (initial != null)

src/Advanced.Algorithms/DataStructures/Heap/BinomialHeap.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,10 @@ private Dictionary<T, List<BinomialHeapNode<T>>> heapMapping
2121

2222
public int Count { get; private set; }
2323

24-
public BinomialHeap(Order order = Order.Ascending)
24+
public BinomialHeap(SortDirection sortDirection = SortDirection.Ascending)
2525
{
26-
this.isMaxHeap = order == Order.Descending;
27-
comparer = new CustomComparer<T>(order, Comparer<T>.Default);
26+
this.isMaxHeap = sortDirection == SortDirection.Descending;
27+
comparer = new CustomComparer<T>(sortDirection, Comparer<T>.Default);
2828
}
2929

3030
/// <summary>

src/Advanced.Algorithms/DataStructures/Heap/FibornacciHeap.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,10 @@ private Dictionary<T, List<FibornacciHeapNode<T>>> heapMapping
2323

2424
public int Count { get; private set; }
2525

26-
public FibornacciHeap(Order order = Order.Ascending)
26+
public FibornacciHeap(SortDirection sortDirection = SortDirection.Ascending)
2727
{
28-
this.isMaxHeap = order == Order.Descending;
29-
comparer = new CustomComparer<T>(order, Comparer<T>.Default);
28+
this.isMaxHeap = sortDirection == SortDirection.Descending;
29+
comparer = new CustomComparer<T>(sortDirection, Comparer<T>.Default);
3030
}
3131

3232
/// <summary>

src/Advanced.Algorithms/DataStructures/Heap/PairingHeap.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@ private Dictionary<T, List<PairingHeapNode<T>>> heapMapping
1919

2020
public int Count { get; private set; }
2121

22-
public PairingHeap(Order order = Order.Ascending)
22+
public PairingHeap(SortDirection sortDirection = SortDirection.Ascending)
2323
{
24-
this.isMaxHeap = order == Order.Descending;
25-
comparer = new CustomComparer<T>(order, Comparer<T>.Default);
24+
this.isMaxHeap = sortDirection == SortDirection.Descending;
25+
comparer = new CustomComparer<T>(sortDirection, Comparer<T>.Default);
2626
}
2727

2828
/// <summary>

src/Advanced.Algorithms/DataStructures/Heap/d-aryHeap.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,10 @@ public class DaryHeap<T> : IEnumerable<T> where T : IComparable
2222
/// </summary>
2323
/// <param name="k">The number of children per heap node.</param>
2424
/// <param name="initial">The initial items if any.</param>
25-
public DaryHeap(int k, Order order = Order.Ascending, IEnumerable<T> initial = null)
25+
public DaryHeap(int k, SortDirection sortDirection = SortDirection.Ascending, IEnumerable<T> initial = null)
2626
{
27-
this.isMaxHeap = order == Order.Descending;
28-
comparer = new CustomComparer<T>(order, Comparer<T>.Default);
27+
this.isMaxHeap = sortDirection == SortDirection.Descending;
28+
comparer = new CustomComparer<T>(sortDirection, Comparer<T>.Default);
2929

3030
if (k <= 2)
3131
{

src/Advanced.Algorithms/DataStructures/Queues/PriorityQueue.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ namespace Advanced.Algorithms.DataStructures
1010
public class PriorityQueue<T> : IEnumerable<T> where T : IComparable
1111
{
1212
private readonly BHeap<T> heap;
13-
public PriorityQueue(Order order = Order.Ascending)
13+
public PriorityQueue(SortDirection sortDirection = SortDirection.Ascending)
1414
{
15-
heap = new BHeap<T>(order);
15+
heap = new BHeap<T>(sortDirection);
1616
}
1717

1818
/// <summary>

src/Advanced.Algorithms/Geometry/BentleyOttmann.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ private void initialize(IEnumerable<Line> lineSegments)
6666
x.Value
6767
}), new PointComparer());
6868

69-
eventQueue = new BHeap<Event>(Order.Ascending, eventQueueLookUp, new EventQueueComparer());
69+
eventQueue = new BHeap<Event>(SortDirection.Ascending, eventQueueLookUp, new EventQueueComparer());
7070
}
7171

7272
public Dictionary<Point, List<Line>> FindIntersections(IEnumerable<Line> lineSegments)

src/Advanced.Algorithms/Search/QuickSelect.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ private static T medianOfMedian(T[] input, int left, int right)
6060
return input[left];
6161
}
6262

63-
var comparer = new CustomComparer<T>(Order.Ascending, Comparer<T>.Default);
63+
var comparer = new CustomComparer<T>(SortDirection.Ascending, Comparer<T>.Default);
6464

6565
var size = 5;
6666
var currentLeft = left;

src/Advanced.Algorithms/Shared/Comparer.cs renamed to src/Advanced.Algorithms/Shared/CustomComparer.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ internal class CustomComparer<T> : IComparer<T> where T : IComparable
1111
private readonly bool isMax;
1212
private readonly IComparer<T> comparer;
1313

14-
internal CustomComparer(Order order, IComparer<T> comparer)
14+
internal CustomComparer(SortDirection sortDirection, IComparer<T> comparer)
1515
{
16-
this.isMax = order == Order.Descending;
16+
this.isMax = sortDirection == SortDirection.Descending;
1717
this.comparer = comparer;
1818
}
1919

src/Advanced.Algorithms/Shared/Order.cs renamed to src/Advanced.Algorithms/Shared/SortDirection.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
namespace Advanced.Algorithms
88
{
9-
public enum Order
9+
public enum SortDirection
1010
{
1111
Ascending = 0,
1212
Descending = 1

0 commit comments

Comments
 (0)