Skip to content

Commit

Permalink
Merge branch 'master' into beta
Browse files Browse the repository at this point in the history
  • Loading branch information
justcoding121 committed Jan 24, 2019
2 parents fed91c9 + 1333e07 commit 748ed6f
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 24 deletions.
20 changes: 16 additions & 4 deletions docs/api/Advanced.Algorithms.DataStructures.RedBlackTree-1.html
Original file line number Diff line number Diff line change
Expand Up @@ -117,14 +117,14 @@ <h3 id="constructors">Constructors


<a id="Advanced_Algorithms_DataStructures_RedBlackTree_1__ctor_" data-uid="Advanced.Algorithms.DataStructures.RedBlackTree`1.#ctor*"></a>
<h4 id="Advanced_Algorithms_DataStructures_RedBlackTree_1__ctor_IEnumerable__0__System_Boolean_" data-uid="Advanced.Algorithms.DataStructures.RedBlackTree`1.#ctor(IEnumerable{`0},System.Boolean)">RedBlackTree(IEnumerable&lt;T&gt;, Boolean)</h4>
<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>
<div class="markdown level1 summary"><p>Initialize the BST with given sorted keys optionally.
Time complexity: O(n).</p>
</div>
<div class="markdown level1 conceptual"></div>
<h5 class="decalaration">Declaration</h5>
<div class="codewrapper">
<pre><code class="lang-csharp hljs">public RedBlackTree(IEnumerable&lt;T&gt; sortedCollection, bool enableNodeLookUp = false)</code></pre>
<pre><code class="lang-csharp hljs">public RedBlackTree(IEnumerable&lt;T&gt; sortedCollection, bool enableNodeLookUp = false, IEqualityComparer&lt;T&gt; equalityComparer = null)</code></pre>
</div>
<h5 class="parameters">Parameters</h5>
<table class="table table-bordered table-striped table-condensed">
Expand All @@ -147,19 +147,25 @@ <h5 class="parameters">Parameters</h5>
<td><span class="parametername">enableNodeLookUp</span></td>
<td><p>Enabling lookup will fasten deletion/insertion/exists operations
at the cost of additional space.</p>
</td>
</tr>
<tr>
<td><span class="xref">IEqualityComparer</span>&lt;T&gt;</td>
<td><span class="parametername">equalityComparer</span></td>
<td><p>Provide equality comparer for node lookup if enabled (required when T is not a value type).</p>
</td>
</tr>
</tbody>
</table>


<a id="Advanced_Algorithms_DataStructures_RedBlackTree_1__ctor_" data-uid="Advanced.Algorithms.DataStructures.RedBlackTree`1.#ctor*"></a>
<h4 id="Advanced_Algorithms_DataStructures_RedBlackTree_1__ctor_System_Boolean_" data-uid="Advanced.Algorithms.DataStructures.RedBlackTree`1.#ctor(System.Boolean)">RedBlackTree(Boolean)</h4>
<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>
<div class="markdown level1 summary"></div>
<div class="markdown level1 conceptual"></div>
<h5 class="decalaration">Declaration</h5>
<div class="codewrapper">
<pre><code class="lang-csharp hljs">public RedBlackTree(bool enableNodeLookUp = false)</code></pre>
<pre><code class="lang-csharp hljs">public RedBlackTree(bool enableNodeLookUp = false, IEqualityComparer&lt;T&gt; equalityComparer = null)</code></pre>
</div>
<h5 class="parameters">Parameters</h5>
<table class="table table-bordered table-striped table-condensed">
Expand All @@ -176,6 +182,12 @@ <h5 class="parameters">Parameters</h5>
<td><span class="parametername">enableNodeLookUp</span></td>
<td><p>Enabling lookup will fasten deletion/insertion/exists operations
at the cost of additional space.</p>
</td>
</tr>
<tr>
<td><span class="xref">IEqualityComparer</span>&lt;T&gt;</td>
<td><span class="parametername">equalityComparer</span></td>
<td><p>Provide equality comparer for node lookup if enabled (required when T is not a value type).</p>
</td>
</tr>
</tbody>
Expand Down
2 changes: 1 addition & 1 deletion docs/index.json
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@
"api/Advanced.Algorithms.DataStructures.RedBlackTree-1.html": {
"href": "api/Advanced.Algorithms.DataStructures.RedBlackTree-1.html",
"title": "Class RedBlackTree<T> | Advanced Algorithms",
"keywords": "Class RedBlackTree<T> A red black tree implementation. Inheritance Object RedBlackTree<T> Namespace : Advanced.Algorithms.DataStructures Assembly : Advanced.Algorithms.dll Syntax public class RedBlackTree<T> : IEnumerable<T> where T : IComparable Type Parameters Name Description T Constructors RedBlackTree(IEnumerable<T>, Boolean) Initialize the BST with given sorted keys optionally. Time complexity: O(n). Declaration public RedBlackTree(IEnumerable<T> sortedCollection, bool enableNodeLookUp = false) Parameters Type Name Description IEnumerable <T> sortedCollection The sorted initial collection. Boolean enableNodeLookUp Enabling lookup will fasten deletion/insertion/exists operations at the cost of additional space. RedBlackTree(Boolean) Declaration public RedBlackTree(bool enableNodeLookUp = false) Parameters Type Name Description Boolean enableNodeLookUp Enabling lookup will fasten deletion/insertion/exists operations at the cost of additional space. 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"
"keywords": "Class RedBlackTree<T> A red black tree implementation. Inheritance Object RedBlackTree<T> Namespace : Advanced.Algorithms.DataStructures Assembly : Advanced.Algorithms.dll Syntax public class RedBlackTree<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 optionally. Time complexity: O(n). Declaration public RedBlackTree(IEnumerable<T> sortedCollection, bool enableNodeLookUp = false, IEqualityComparer<T> equalityComparer = null) Parameters Type Name Description IEnumerable <T> sortedCollection The sorted initial collection. Boolean enableNodeLookUp Enabling lookup will fasten deletion/insertion/exists operations at the cost of additional space. IEqualityComparer <T> equalityComparer Provide equality comparer for node lookup if enabled (required when T is not a value type). 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 equality comparer for node lookup if enabled (required when T is not a value type). 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"
},
"api/Advanced.Algorithms.DataStructures.RTree.html": {
"href": "api/Advanced.Algorithms.DataStructures.RTree.html",
Expand Down
35 changes: 18 additions & 17 deletions docs/xrefmap.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6180,23 +6180,24 @@ references:
fullName.vb: Advanced.Algorithms.DataStructures.RedBlackTree(Of T)
nameWithType: RedBlackTree<T>
nameWithType.vb: RedBlackTree(Of T)
- uid: Advanced.Algorithms.DataStructures.RedBlackTree`1.#ctor(IEnumerable{`0},System.Boolean)
name: RedBlackTree(IEnumerable<T>, Boolean)
href: api/Advanced.Algorithms.DataStructures.RedBlackTree-1.html#Advanced_Algorithms_DataStructures_RedBlackTree_1__ctor_IEnumerable__0__System_Boolean_
commentId: M:Advanced.Algorithms.DataStructures.RedBlackTree`1.#ctor(IEnumerable{`0},System.Boolean)
name.vb: RedBlackTree(IEnumerable(Of T), Boolean)
fullName: Advanced.Algorithms.DataStructures.RedBlackTree<T>.RedBlackTree(IEnumerable<T>, System.Boolean)
fullName.vb: Advanced.Algorithms.DataStructures.RedBlackTree(Of T).RedBlackTree(IEnumerable(Of T), System.Boolean)
nameWithType: RedBlackTree<T>.RedBlackTree(IEnumerable<T>, Boolean)
nameWithType.vb: RedBlackTree(Of T).RedBlackTree(IEnumerable(Of T), Boolean)
- uid: Advanced.Algorithms.DataStructures.RedBlackTree`1.#ctor(System.Boolean)
name: RedBlackTree(Boolean)
href: api/Advanced.Algorithms.DataStructures.RedBlackTree-1.html#Advanced_Algorithms_DataStructures_RedBlackTree_1__ctor_System_Boolean_
commentId: M:Advanced.Algorithms.DataStructures.RedBlackTree`1.#ctor(System.Boolean)
fullName: Advanced.Algorithms.DataStructures.RedBlackTree<T>.RedBlackTree(System.Boolean)
fullName.vb: Advanced.Algorithms.DataStructures.RedBlackTree(Of T).RedBlackTree(System.Boolean)
nameWithType: RedBlackTree<T>.RedBlackTree(Boolean)
nameWithType.vb: RedBlackTree(Of T).RedBlackTree(Boolean)
- uid: Advanced.Algorithms.DataStructures.RedBlackTree`1.#ctor(IEnumerable{`0},System.Boolean,IEqualityComparer{`0})
name: RedBlackTree(IEnumerable<T>, Boolean, IEqualityComparer<T>)
href: api/Advanced.Algorithms.DataStructures.RedBlackTree-1.html#Advanced_Algorithms_DataStructures_RedBlackTree_1__ctor_IEnumerable__0__System_Boolean_IEqualityComparer__0__
commentId: M:Advanced.Algorithms.DataStructures.RedBlackTree`1.#ctor(IEnumerable{`0},System.Boolean,IEqualityComparer{`0})
name.vb: RedBlackTree(IEnumerable(Of T), Boolean, IEqualityComparer(Of T))
fullName: Advanced.Algorithms.DataStructures.RedBlackTree<T>.RedBlackTree(IEnumerable<T>, System.Boolean, IEqualityComparer<T>)
fullName.vb: Advanced.Algorithms.DataStructures.RedBlackTree(Of T).RedBlackTree(IEnumerable(Of T), System.Boolean, IEqualityComparer(Of T))
nameWithType: RedBlackTree<T>.RedBlackTree(IEnumerable<T>, Boolean, IEqualityComparer<T>)
nameWithType.vb: RedBlackTree(Of T).RedBlackTree(IEnumerable(Of T), Boolean, IEqualityComparer(Of T))
- uid: Advanced.Algorithms.DataStructures.RedBlackTree`1.#ctor(System.Boolean,IEqualityComparer{`0})
name: RedBlackTree(Boolean, IEqualityComparer<T>)
href: api/Advanced.Algorithms.DataStructures.RedBlackTree-1.html#Advanced_Algorithms_DataStructures_RedBlackTree_1__ctor_System_Boolean_IEqualityComparer__0__
commentId: M:Advanced.Algorithms.DataStructures.RedBlackTree`1.#ctor(System.Boolean,IEqualityComparer{`0})
name.vb: RedBlackTree(Boolean, IEqualityComparer(Of T))
fullName: Advanced.Algorithms.DataStructures.RedBlackTree<T>.RedBlackTree(System.Boolean, IEqualityComparer<T>)
fullName.vb: Advanced.Algorithms.DataStructures.RedBlackTree(Of T).RedBlackTree(System.Boolean, IEqualityComparer(Of T))
nameWithType: RedBlackTree<T>.RedBlackTree(Boolean, IEqualityComparer<T>)
nameWithType.vb: RedBlackTree(Of T).RedBlackTree(Boolean, IEqualityComparer(Of T))
- uid: Advanced.Algorithms.DataStructures.RedBlackTree`1.#ctor*
name: RedBlackTree
href: api/Advanced.Algorithms.DataStructures.RedBlackTree-1.html#Advanced_Algorithms_DataStructures_RedBlackTree_1__ctor_
Expand Down
4 changes: 2 additions & 2 deletions src/Advanced.Algorithms/DataStructures/Tree/RedBlackTree.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public RedBlackTree(bool enableNodeLookUp = false, IEqualityComparer<T> equality
throw new ArgumentException("equalityComparer parameter is required when node lookup us enabled and T is not a value type.");
}

NodeLookUp = new Dictionary<T, BSTNodeBase<T>>(equalityComparer);
NodeLookUp = new Dictionary<T, BSTNodeBase<T>>(equalityComparer ?? EqualityComparer<T>.Default);
}
}

Expand Down Expand Up @@ -58,7 +58,7 @@ public RedBlackTree(IEnumerable<T> sortedCollection, bool enableNodeLookUp = fal
throw new ArgumentException("equalityComparer parameter is required when node lookup us enabled and T is not a value type.");
}

NodeLookUp = nodes.ToDictionary(x => x.Value, x => x as BSTNodeBase<T>);
NodeLookUp = nodes.ToDictionary(x => x.Value, x => x as BSTNodeBase<T>, equalityComparer ?? EqualityComparer<T>.Default);
}
}

Expand Down

0 comments on commit 748ed6f

Please sign in to comment.