Skip to content

Commit a56eb2a

Browse files
committed
rename bst inital collection param
1 parent 427c661 commit a56eb2a

File tree

6 files changed

+22
-25
lines changed

6 files changed

+22
-25
lines changed

src/Advanced.Algorithms/DataStructures/Tree/AvlTree.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,14 @@ public AVLTree(bool enableNodeLookUp = false)
3030
/// Initialize the BST with given sorted keys.
3131
/// Time complexity: O(n).
3232
/// </summary>
33-
/// <param name="sortedKeys">The sorted keys.</param>
33+
/// <param name="sortedCollection">The initial sorted collection.</param>
3434
/// <param name="enableNodeLookUp">Enabling lookup will fasten deletion/insertion/exists operations
3535
/// at the cost of additional space.</param>
36-
public AVLTree(IEnumerable<T> sortedKeys, bool enableNodeLookUp = false)
36+
public AVLTree(IEnumerable<T> sortedCollection, bool enableNodeLookUp = false)
3737
: this(enableNodeLookUp)
3838
{
39-
ValidateCollection(sortedKeys);
40-
var nodes = sortedKeys.Select(x => new AVLTreeNode<T>(null, x)).ToArray();
39+
ValidateSortedCollection(sortedCollection);
40+
var nodes = sortedCollection.Select(x => new AVLTreeNode<T>(null, x)).ToArray();
4141
Root = (AVLTreeNode<T>)ToBST(nodes);
4242
recomputeHeight(Root);
4343
assignCount(Root);

src/Advanced.Algorithms/DataStructures/Tree/BST.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@ public BST() { }
2020
/// Initialize the BST with given sorted keys.
2121
/// Time complexity: O(n).
2222
/// </summary>
23-
public BST(IEnumerable<T> sortedKeys) : this()
23+
public BST(IEnumerable<T> sortedCollection) : this()
2424
{
25-
ValidateCollection(sortedKeys);
26-
var nodes = sortedKeys.Select(x => new BSTNode<T>(null, x)).ToArray();
25+
ValidateSortedCollection(sortedCollection);
26+
var nodes = sortedCollection.Select(x => new BSTNode<T>(null, x)).ToArray();
2727
Root = (BSTNode<T>)ToBST(nodes);
2828
assignCount(Root);
2929
}

src/Advanced.Algorithms/DataStructures/Tree/RedBlackTree.cs

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,16 +21,13 @@ public class RedBlackTree<T> : BSTBase<T>, IEnumerable<T> where T : IComparable
2121
/// Initialize the BST with given sorted keys optionally.
2222
/// Time complexity: O(n).
2323
/// </summary>
24-
/// <param name="collection">The sorted keys.</param>
25-
/// <param name="enableNodeLookUp">Enabling lookup will fasten deletion/insertion/exists operations
26-
/// at the cost of additional space.</param>
27-
/// <param name="equalityComparer">Provide custom IEquality comparer for node lookup dictionary when enabled.</param>
28-
public RedBlackTree(IEnumerable<T> sortedKeys = null)
24+
/// <param name="sortedCollection">The sorted initial collection.</param>
25+
public RedBlackTree(IEnumerable<T> sortedCollection = null)
2926
{
30-
if (sortedKeys != null)
27+
if (sortedCollection != null)
3128
{
32-
ValidateCollection(sortedKeys);
33-
var nodes = sortedKeys.Select(x => new RedBlackTreeNode<T>(null, x)).ToArray();
29+
ValidateSortedCollection(sortedCollection);
30+
var nodes = sortedCollection.Select(x => new RedBlackTreeNode<T>(null, x)).ToArray();
3431
Root = (RedBlackTreeNode<T>)ToBST(nodes);
3532
assignColors(Root);
3633
assignCount(Root);

src/Advanced.Algorithms/DataStructures/Tree/Shared/BSTBase.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ namespace Advanced.Algorithms.DataStructures
55
{
66
public class BSTBase<T> where T : IComparable
77
{
8-
internal void ValidateCollection(IEnumerable<T> collection)
8+
internal void ValidateSortedCollection(IEnumerable<T> sortedCollection)
99
{
10-
if (!isSorted(collection))
10+
if (!isSorted(sortedCollection))
1111
{
1212
throw new ArgumentException("Initial collection should have unique keys and be in sorted order.");
1313
}

src/Advanced.Algorithms/DataStructures/Tree/SplayTree.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,11 @@ public SplayTree() { }
1818
/// Initialize the BST with given sorted keys.
1919
/// Time complexity: O(n).
2020
/// </summary>
21-
/// <param name="sortedKeys">The sorted keys.</param>
22-
public SplayTree(IEnumerable<T> collection) : this()
21+
/// <param name="sortedCollection">The sorted collection.</param>
22+
public SplayTree(IEnumerable<T> sortedCollection) : this()
2323
{
24-
ValidateCollection(collection);
25-
var nodes = collection.Select(x => new SplayTreeNode<T>(null, x)).ToArray();
24+
ValidateSortedCollection(sortedCollection);
25+
var nodes = sortedCollection.Select(x => new SplayTreeNode<T>(null, x)).ToArray();
2626
Root = (SplayTreeNode<T>)ToBST(nodes);
2727
assignCount(Root);
2828
}

src/Advanced.Algorithms/DataStructures/Tree/TreapTree.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,11 @@ public TreapTree() { }
2020
/// Initialize the BST with given sorted keys.
2121
/// Time complexity: O(n).
2222
/// </summary>
23-
/// <param name="sortedKeys">The sorted keys.</param>
24-
public TreapTree(IEnumerable<T> collection) : this()
23+
/// <param name="sortedCollection">The initial sorted collection.</param>
24+
public TreapTree(IEnumerable<T> sortedCollection) : this()
2525
{
26-
ValidateCollection(collection);
27-
var nodes = collection.Select(x => new TreapTreeNode<T>(null, x, rndGenerator.Next())).ToArray();
26+
ValidateSortedCollection(sortedCollection);
27+
var nodes = sortedCollection.Select(x => new TreapTreeNode<T>(null, x, rndGenerator.Next())).ToArray();
2828
Root = (TreapTreeNode<T>)ToBST(nodes);
2929
assignCount(Root);
3030
heapify(Root);

0 commit comments

Comments
 (0)