Skip to content

Commit 6c74c1d

Browse files
committed
Merge branch 'master' into beta
2 parents 34dce58 + 8a196ee commit 6c74c1d

File tree

9 files changed

+35
-95
lines changed

9 files changed

+35
-95
lines changed

docs/api/Advanced.Algorithms.DataStructures.RedBlackTree-1.html

Lines changed: 3 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -122,14 +122,14 @@ <h3 id="constructors">Constructors
122122

123123

124124
<a id="Advanced_Algorithms_DataStructures_RedBlackTree_1__ctor_" data-uid="Advanced.Algorithms.DataStructures.RedBlackTree`1.#ctor*"></a>
125-
<h4 id="Advanced_Algorithms_DataStructures_RedBlackTree_1__ctor_IEnumerable__0__System_Boolean_IEqualityComparer__0__" data-uid="Advanced.Algorithms.DataStructures.RedBlackTree`1.#ctor(IEnumerable{`0},System.Boolean,IEqualityComparer{`0})">RedBlackTree(IEnumerable&lt;T&gt;, Boolean, IEqualityComparer&lt;T&gt;)</h4>
126-
<div class="markdown level1 summary"><p>Initialize the BST with given sorted keys.
125+
<h4 id="Advanced_Algorithms_DataStructures_RedBlackTree_1__ctor_IEnumerable__0__" data-uid="Advanced.Algorithms.DataStructures.RedBlackTree`1.#ctor(IEnumerable{`0})">RedBlackTree(IEnumerable&lt;T&gt;)</h4>
126+
<div class="markdown level1 summary"><p>Initialize the BST with given sorted keys optionally.
127127
Time complexity: O(n).</p>
128128
</div>
129129
<div class="markdown level1 conceptual"></div>
130130
<h5 class="decalaration">Declaration</h5>
131131
<div class="codewrapper">
132-
<pre><code class="lang-csharp hljs">public RedBlackTree(IEnumerable&lt;T&gt; sortedKeys, bool enableNodeLookUp = false, IEqualityComparer&lt;T&gt; equalityComparer = null)</code></pre>
132+
<pre><code class="lang-csharp hljs">public RedBlackTree(IEnumerable&lt;T&gt; sortedKeys = null)</code></pre>
133133
</div>
134134
<h5 class="parameters">Parameters</h5>
135135
<table class="table table-bordered table-striped table-condensed">
@@ -146,54 +146,6 @@ <h5 class="parameters">Parameters</h5>
146146
<td><span class="parametername">sortedKeys</span></td>
147147
<td></td>
148148
</tr>
149-
<tr>
150-
<td><a class="xref" href="https://docs.microsoft.com/dotnet/api/system.boolean">Boolean</a></td>
151-
<td><span class="parametername">enableNodeLookUp</span></td>
152-
<td><p>Enabling lookup will fasten deletion/insertion/exists operations
153-
at the cost of additional space.</p>
154-
</td>
155-
</tr>
156-
<tr>
157-
<td><span class="xref">IEqualityComparer</span>&lt;T&gt;</td>
158-
<td><span class="parametername">equalityComparer</span></td>
159-
<td><p>Provide custom IEquality comparer for node lookup dictionary when enabled.</p>
160-
</td>
161-
</tr>
162-
</tbody>
163-
</table>
164-
165-
166-
<a id="Advanced_Algorithms_DataStructures_RedBlackTree_1__ctor_" data-uid="Advanced.Algorithms.DataStructures.RedBlackTree`1.#ctor*"></a>
167-
<h4 id="Advanced_Algorithms_DataStructures_RedBlackTree_1__ctor_System_Boolean_IEqualityComparer__0__" data-uid="Advanced.Algorithms.DataStructures.RedBlackTree`1.#ctor(System.Boolean,IEqualityComparer{`0})">RedBlackTree(Boolean, IEqualityComparer&lt;T&gt;)</h4>
168-
<div class="markdown level1 summary"></div>
169-
<div class="markdown level1 conceptual"></div>
170-
<h5 class="decalaration">Declaration</h5>
171-
<div class="codewrapper">
172-
<pre><code class="lang-csharp hljs">public RedBlackTree(bool enableNodeLookUp = false, IEqualityComparer&lt;T&gt; equalityComparer = null)</code></pre>
173-
</div>
174-
<h5 class="parameters">Parameters</h5>
175-
<table class="table table-bordered table-striped table-condensed">
176-
<thead>
177-
<tr>
178-
<th>Type</th>
179-
<th>Name</th>
180-
<th>Description</th>
181-
</tr>
182-
</thead>
183-
<tbody>
184-
<tr>
185-
<td><a class="xref" href="https://docs.microsoft.com/dotnet/api/system.boolean">Boolean</a></td>
186-
<td><span class="parametername">enableNodeLookUp</span></td>
187-
<td><p>Enabling lookup will fasten deletion/insertion/exists operations
188-
at the cost of additional space.</p>
189-
</td>
190-
</tr>
191-
<tr>
192-
<td><span class="xref">IEqualityComparer</span>&lt;T&gt;</td>
193-
<td><span class="parametername">equalityComparer</span></td>
194-
<td><p>Provide custom IEquality comparer for node lookup dictionary when enabled.</p>
195-
</td>
196-
</tr>
197149
</tbody>
198150
</table>
199151
<h3 id="properties">Properties

docs/index.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,7 @@
302302
"api/Advanced.Algorithms.DataStructures.RedBlackTree-1.html": {
303303
"href": "api/Advanced.Algorithms.DataStructures.RedBlackTree-1.html",
304304
"title": "Class RedBlackTree<T> | Advanced Algorithms",
305-
"keywords": "Class RedBlackTree<T> A red black tree implementation. Inheritance Object BSTBase <T> RedBlackTree<T> Implements IEnumerable <T> Namespace : Advanced.Algorithms.DataStructures Assembly : Advanced.Algorithms.dll Syntax public class RedBlackTree<T> : BSTBase<T>, IEnumerable<T> where T : IComparable Type Parameters Name Description T Constructors RedBlackTree(IEnumerable<T>, Boolean, IEqualityComparer<T>) Initialize the BST with given sorted keys. Time complexity: O(n). Declaration public RedBlackTree(IEnumerable<T> sortedKeys, bool enableNodeLookUp = false, IEqualityComparer<T> equalityComparer = null) Parameters Type Name Description IEnumerable <T> sortedKeys Boolean enableNodeLookUp Enabling lookup will fasten deletion/insertion/exists operations at the cost of additional space. IEqualityComparer <T> equalityComparer Provide custom IEquality comparer for node lookup dictionary when enabled. RedBlackTree(Boolean, IEqualityComparer<T>) Declaration public RedBlackTree(bool enableNodeLookUp = false, IEqualityComparer<T> equalityComparer = null) Parameters Type Name Description Boolean enableNodeLookUp Enabling lookup will fasten deletion/insertion/exists operations at the cost of additional space. IEqualityComparer <T> equalityComparer Provide custom IEquality comparer for node lookup dictionary when enabled. Properties Count Declaration public int Count { get; } Property Value Type Description Int32 Methods AsEnumerableDesc() Descending enumerable. Declaration public IEnumerable<T> AsEnumerableDesc() Returns Type Description IEnumerable <T> Delete(T) Delete if value exists. Time complexity: O(log(n)) Returns the position (index) of the item if deleted; otherwise returns -1 Declaration public int Delete(T value) Parameters Type Name Description T value Returns Type Description Int32 ElementAt(Int32) Time complexity: O(log(n)) Declaration public T ElementAt(int index) Parameters Type Name Description Int32 index Returns Type Description T GetEnumerator() Declaration public IEnumerator<T> GetEnumerator() Returns Type Description IEnumerator <T> GetEnumeratorDesc() Declaration public IEnumerator<T> GetEnumeratorDesc() Returns Type Description IEnumerator <T> HasItem(T) Time complexity: O(log(n)) Declaration public bool HasItem(T value) Parameters Type Name Description T value Returns Type Description Boolean IndexOf(T) Time complexity: O(log(n)) Declaration public int IndexOf(T item) Parameters Type Name Description T item Returns Type Description Int32 Insert(T) Time complexity: O(log(n)). Returns the position (index) of the value in sorted order of this BST. Declaration public int Insert(T value) Parameters Type Name Description T value Returns Type Description Int32 Max() Time complexity: O(log(n)) Declaration public T Max() Returns Type Description T Min() Time complexity: O(log(n)) Declaration public T Min() Returns Type Description T NextHigher(T) Get the next higher to given value in this BST. Declaration public T NextHigher(T value) Parameters Type Name Description T value Returns Type Description T NextLower(T) Get the next lower value to given value in this BST. Declaration public T NextLower(T value) Parameters Type Name Description T value Returns Type Description T RemoveAt(Int32) Time complexity: O(log(n)) Declaration public T RemoveAt(int index) Parameters Type Name Description Int32 index Returns Type Description T Implements IEnumerable<>"
305+
"keywords": "Class RedBlackTree<T> A red black tree implementation. Inheritance Object BSTBase <T> RedBlackTree<T> Implements IEnumerable <T> Namespace : Advanced.Algorithms.DataStructures Assembly : Advanced.Algorithms.dll Syntax public class RedBlackTree<T> : BSTBase<T>, IEnumerable<T> where T : IComparable Type Parameters Name Description T Constructors RedBlackTree(IEnumerable<T>) Initialize the BST with given sorted keys optionally. Time complexity: O(n). Declaration public RedBlackTree(IEnumerable<T> sortedKeys = null) Parameters Type Name Description IEnumerable <T> sortedKeys Properties Count Declaration public int Count { get; } Property Value Type Description Int32 Methods AsEnumerableDesc() Descending enumerable. Declaration public IEnumerable<T> AsEnumerableDesc() Returns Type Description IEnumerable <T> Delete(T) Delete if value exists. Time complexity: O(log(n)) Returns the position (index) of the item if deleted; otherwise returns -1 Declaration public int Delete(T value) Parameters Type Name Description T value Returns Type Description Int32 ElementAt(Int32) Time complexity: O(log(n)) Declaration public T ElementAt(int index) Parameters Type Name Description Int32 index Returns Type Description T GetEnumerator() Declaration public IEnumerator<T> GetEnumerator() Returns Type Description IEnumerator <T> GetEnumeratorDesc() Declaration public IEnumerator<T> GetEnumeratorDesc() Returns Type Description IEnumerator <T> HasItem(T) Time complexity: O(log(n)) Declaration public bool HasItem(T value) Parameters Type Name Description T value Returns Type Description Boolean IndexOf(T) Time complexity: O(log(n)) Declaration public int IndexOf(T item) Parameters Type Name Description T item Returns Type Description Int32 Insert(T) Time complexity: O(log(n)). Returns the position (index) of the value in sorted order of this BST. Declaration public int Insert(T value) Parameters Type Name Description T value Returns Type Description Int32 Max() Time complexity: O(log(n)) Declaration public T Max() Returns Type Description T Min() Time complexity: O(log(n)) Declaration public T Min() Returns Type Description T NextHigher(T) Get the next higher to given value in this BST. Declaration public T NextHigher(T value) Parameters Type Name Description T value Returns Type Description T NextLower(T) Get the next lower value to given value in this BST. Declaration public T NextLower(T value) Parameters Type Name Description T value Returns Type Description T RemoveAt(Int32) Time complexity: O(log(n)) Declaration public T RemoveAt(int index) Parameters Type Name Description Int32 index Returns Type Description T Implements IEnumerable<>"
306306
},
307307
"api/Advanced.Algorithms.DataStructures.RTree.html": {
308308
"href": "api/Advanced.Algorithms.DataStructures.RTree.html",

docs/xrefmap.yml

Lines changed: 9 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -6189,24 +6189,15 @@ references:
61896189
fullName.vb: Advanced.Algorithms.DataStructures.RedBlackTree(Of T)
61906190
nameWithType: RedBlackTree<T>
61916191
nameWithType.vb: RedBlackTree(Of T)
6192-
- uid: Advanced.Algorithms.DataStructures.RedBlackTree`1.#ctor(IEnumerable{`0},System.Boolean,IEqualityComparer{`0})
6193-
name: RedBlackTree(IEnumerable<T>, Boolean, IEqualityComparer<T>)
6194-
href: api/Advanced.Algorithms.DataStructures.RedBlackTree-1.html#Advanced_Algorithms_DataStructures_RedBlackTree_1__ctor_IEnumerable__0__System_Boolean_IEqualityComparer__0__
6195-
commentId: M:Advanced.Algorithms.DataStructures.RedBlackTree`1.#ctor(IEnumerable{`0},System.Boolean,IEqualityComparer{`0})
6196-
name.vb: RedBlackTree(IEnumerable(Of T), Boolean, IEqualityComparer(Of T))
6197-
fullName: Advanced.Algorithms.DataStructures.RedBlackTree<T>.RedBlackTree(IEnumerable<T>, System.Boolean, IEqualityComparer<T>)
6198-
fullName.vb: Advanced.Algorithms.DataStructures.RedBlackTree(Of T).RedBlackTree(IEnumerable(Of T), System.Boolean, IEqualityComparer(Of T))
6199-
nameWithType: RedBlackTree<T>.RedBlackTree(IEnumerable<T>, Boolean, IEqualityComparer<T>)
6200-
nameWithType.vb: RedBlackTree(Of T).RedBlackTree(IEnumerable(Of T), Boolean, IEqualityComparer(Of T))
6201-
- uid: Advanced.Algorithms.DataStructures.RedBlackTree`1.#ctor(System.Boolean,IEqualityComparer{`0})
6202-
name: RedBlackTree(Boolean, IEqualityComparer<T>)
6203-
href: api/Advanced.Algorithms.DataStructures.RedBlackTree-1.html#Advanced_Algorithms_DataStructures_RedBlackTree_1__ctor_System_Boolean_IEqualityComparer__0__
6204-
commentId: M:Advanced.Algorithms.DataStructures.RedBlackTree`1.#ctor(System.Boolean,IEqualityComparer{`0})
6205-
name.vb: RedBlackTree(Boolean, IEqualityComparer(Of T))
6206-
fullName: Advanced.Algorithms.DataStructures.RedBlackTree<T>.RedBlackTree(System.Boolean, IEqualityComparer<T>)
6207-
fullName.vb: Advanced.Algorithms.DataStructures.RedBlackTree(Of T).RedBlackTree(System.Boolean, IEqualityComparer(Of T))
6208-
nameWithType: RedBlackTree<T>.RedBlackTree(Boolean, IEqualityComparer<T>)
6209-
nameWithType.vb: RedBlackTree(Of T).RedBlackTree(Boolean, IEqualityComparer(Of T))
6192+
- uid: Advanced.Algorithms.DataStructures.RedBlackTree`1.#ctor(IEnumerable{`0})
6193+
name: RedBlackTree(IEnumerable<T>)
6194+
href: api/Advanced.Algorithms.DataStructures.RedBlackTree-1.html#Advanced_Algorithms_DataStructures_RedBlackTree_1__ctor_IEnumerable__0__
6195+
commentId: M:Advanced.Algorithms.DataStructures.RedBlackTree`1.#ctor(IEnumerable{`0})
6196+
name.vb: RedBlackTree(IEnumerable(Of T))
6197+
fullName: Advanced.Algorithms.DataStructures.RedBlackTree<T>.RedBlackTree(IEnumerable<T>)
6198+
fullName.vb: Advanced.Algorithms.DataStructures.RedBlackTree(Of T).RedBlackTree(IEnumerable(Of T))
6199+
nameWithType: RedBlackTree<T>.RedBlackTree(IEnumerable<T>)
6200+
nameWithType.vb: RedBlackTree(Of T).RedBlackTree(IEnumerable(Of T))
62106201
- uid: Advanced.Algorithms.DataStructures.RedBlackTree`1.#ctor*
62116202
name: RedBlackTree
62126203
href: api/Advanced.Algorithms.DataStructures.RedBlackTree-1.html#Advanced_Algorithms_DataStructures_RedBlackTree_1__ctor_

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)