Skip to content

Commit 51a547c

Browse files
committed
Removed warnings and done summary refactoring
1 parent ccabd95 commit 51a547c

9 files changed

Lines changed: 234 additions & 141 deletions

DStruct/BinaryTrees/AVLTree.cs

Lines changed: 27 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,51 @@
1-
using DStruct.Queues;
2-
using System;
1+
using System;
32
using System.Collections.Generic;
43

54
// ReSharper disable RedundantAssignment
65

76
namespace DStruct.BinaryTrees
87
{
9-
/// <summary>Represents a node-based, self-balancing <see cref="IBinarySearchTree{T}"/> enhanced to implement an efficient indexer.</summary>
8+
/// <summary>
9+
/// Represents a node-based, self-balancing <see cref="IBinarySearchTree{T}"/> enhanced to implement an efficient indexer.
10+
/// </summary>
1011
/// <typeparam name="T">The type of the values stored in the <see cref="AVLTree{T}"/>.</typeparam>
1112
public class AVLTree<T> : BinarySearchTreeBase<T>
1213
{
1314
private AVLTreeNode<T> _root;
1415

15-
/// <summary>Initializes a new instance of <see cref="AVLTree{T}"/> that is empty.</summary>
16+
private protected override IBinarySearchTreeNode<T> Root => _root;
17+
18+
/// <summary>
19+
/// Initializes a new instance of <see cref="AVLTree{T}"/> that is empty.
20+
/// </summary>
1621
public AVLTree()
1722
{
1823
}
1924

20-
/// <summary>Initializes a new instance of <see cref="AVLTree{T}"/> that contains every item from the input collection.</summary>
25+
/// <summary>
26+
/// Initializes a new instance of <see cref="AVLTree{T}"/> that contains every item from the input collection.
27+
/// </summary>
2128
/// <param name="collection">The collection of elements to add to the <see cref="AVLTree{T}"/>.</param>
2229
/// <exception cref="ArgumentNullException"><paramref name="collection"/> is <c>null</c>.</exception>
2330
public AVLTree(IEnumerable<T> collection)
2431
: base(collection)
2532
{
2633
}
2734

28-
/// <summary>Initializes a new instance of <see cref="AVLTree{T}"/> that is empty and uses the specified <see cref="IComparer{T}"/>.</summary>
35+
/// <summary>
36+
/// Initializes a new instance of <see cref="AVLTree{T}"/> that is empty and uses the specified <see cref="IComparer{T}"/>.
37+
/// </summary>
2938
/// <param name="comparer">The <see cref="IComparer{T}"/> that will be used for making comparisons.</param>
3039
/// <exception cref="ArgumentNullException"><paramref name="comparer"/> is <c>null</c>.</exception>
3140
public AVLTree(IComparer<T> comparer)
3241
: base(comparer)
3342
{
3443
}
3544

36-
private protected override IBinarySearchTreeNode<T> Root => _root;
37-
38-
/// <summary>Inserts an element into the <see cref="AVLTree{T}" /> and returns its index. <code>Complexity: O(LogN)</code></summary>
45+
/// <summary>
46+
/// Inserts an element into the <see cref="AVLTree{T}" /> and returns its index.
47+
/// <code>Complexity: O(LogN)</code>
48+
/// </summary>
3949
/// <param name="value">The element to add to the <see cref="AVLTree{T}"/>.</param>
4050
/// <returns>The index at which the element was placed.</returns>
4151
public override int Insert(T value)
@@ -71,7 +81,10 @@ void InsertHelper(ref AVLTreeNode<T> node)
7181
return position;
7282
}
7383

74-
/// <summary>Determines whether the <see cref="AVLTree{T}" /> contains a specific value. <code>Complexity: O(LogN)</code></summary>
84+
/// <summary>
85+
/// Determines whether the <see cref="AVLTree{T}" /> contains a specific value.
86+
/// <code>Complexity: O(LogN)</code>
87+
/// </summary>
7588
/// <param name="value">The element to locate in the <see cref="AVLTree{T}"/>.</param>
7689
/// <returns><c>true</c> if the <see cref="AVLTree{T}"/> contains <paramref name="value"/>; <c>false</c> otherwise.</returns>
7790
public override bool Find(T value)
@@ -97,7 +110,10 @@ public override bool Find(T value)
97110
return false;
98111
}
99112

100-
/// <summary>Removes one occurrence of a specific element from the <see cref="AVLTree{T}" />. <code>Complexity: O(LogN)</code></summary>
113+
/// <summary>
114+
/// Removes one occurrence of a specific element from the <see cref="AVLTree{T}" />.
115+
/// <code>Complexity: O(LogN)</code>
116+
/// </summary>
101117
/// <param name="value">The element to remove from the <see cref="AVLTree{T}"/>.</param>
102118
/// <returns><c>true</c> if the element was successfully removed from the <see cref="AVLTree{T}"/>; <c>false</c> otherwise.</returns>
103119
public override bool Remove(T value)

DStruct/BinaryTrees/AVLTreeNode.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22

33
namespace DStruct.BinaryTrees
44
{
5-
internal class AVLTreeNode<T> : IBinarySearchTreeNode<T>
5+
class AVLTreeNode<T> : IBinarySearchTreeNode<T>
66
{
7+
public T Value { get; set; }
8+
79
public AVLTreeNode<T> Left;
810
public AVLTreeNode<T> Right;
911

10-
public T Value { get; set; }
11-
1212
public int LeftChildren { get; set; }
1313
public int Height { get; set; }
1414

DStruct/BinaryTrees/BSTNode.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
namespace DStruct.BinaryTrees
22
{
3-
internal class BSTNode<T> : IBinarySearchTreeNode<T>
3+
class BSTNode<T> : IBinarySearchTreeNode<T>
44
{
5+
public T Value { get; set; }
6+
57
public BSTNode<T> Left;
68
public BSTNode<T> Right;
79

8-
public T Value { get; set; }
910
public int LeftChildren { get; set; }
1011

1112
IBinarySearchTreeNode<T> IBinarySearchTreeNode<T>.Left => Left;

DStruct/BinaryTrees/BinarySearchTree.cs

Lines changed: 26 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,36 +5,47 @@
55

66
namespace DStruct.BinaryTrees
77
{
8-
/// <summary>Represents a node-based, non self-balancing <see cref="IBinarySearchTree{T}" /> enhanced to implement an efficient indexer.</summary>
8+
/// <summary>
9+
/// Represents a node-based, non self-balancing <see cref="IBinarySearchTree{T}" /> enhanced to implement an efficient indexer.
10+
/// </summary>
911
/// <typeparam name="T">The type of the values stored in the <see cref="BinarySearchTree{T}"/>.</typeparam>
1012
public class BinarySearchTree<T> : BinarySearchTreeBase<T>
1113
{
1214
private BSTNode<T> _root;
1315

14-
/// <summary>Initializes a new instance of <see cref="BinarySearchTree{T}"/> that is empty.</summary>
16+
private protected override IBinarySearchTreeNode<T> Root => _root;
17+
18+
/// <summary>
19+
/// Initializes a new instance of <see cref="BinarySearchTree{T}"/> that is empty.
20+
/// </summary>
1521
public BinarySearchTree()
1622
{
1723
}
1824

19-
/// <summary>Initializes a new instance of <see cref="BinarySearchTree{T}"/> that contains every item from the input collection.</summary>
25+
/// <summary>
26+
/// Initializes a new instance of <see cref="BinarySearchTree{T}"/> that contains every item from the input collection.
27+
/// </summary>
2028
/// <param name="collection">The collection of elements to add to the <see cref="BinarySearchTree{T}"/>.</param>
2129
/// <exception cref="ArgumentNullException"><paramref name="collection"/> is <c>null</c>.</exception>
2230
public BinarySearchTree(IEnumerable<T> collection)
2331
: base(collection)
2432
{
2533
}
2634

27-
/// <summary>Initializes a new instance of <see cref="BinarySearchTree{T}"/> that is empty and uses the specified <see cref="IComparer{T}"/>.</summary>
35+
/// <summary>
36+
/// Initializes a new instance of <see cref="BinarySearchTree{T}"/> that is empty and uses the specified <see cref="IComparer{T}"/>.
37+
/// </summary>
2838
/// <param name="comparer">The <see cref="IComparer{T}"/> that will be used for making comparisons.</param>
2939
/// <exception cref="ArgumentNullException"><paramref name="comparer"/> is <c>null</c>.</exception>
3040
public BinarySearchTree(IComparer<T> comparer)
3141
: base(comparer)
3242
{
3343
}
3444

35-
private protected override IBinarySearchTreeNode<T> Root => _root;
36-
37-
/// <summary>Inserts an element into the <see cref="BinarySearchTree{T}" /> and returns its index. <code>Complexity: avg O(LogN), worst O(N)</code></summary>
45+
/// <summary>
46+
/// Inserts an element into the <see cref="BinarySearchTree{T}" /> and returns its index.
47+
/// <code>Complexity: avg O(LogN), worst O(N)</code>
48+
/// </summary>
3849
/// <param name="value">The element to add to the <see cref="BinarySearchTree{T}"/>.</param>
3950
/// <returns>The index at which the element was placed.</returns>
4051
public override int Insert(T value)
@@ -63,7 +74,10 @@ public override int Insert(T value)
6374
return position;
6475
}
6576

66-
/// <summary>Determines whether the <see cref="BinarySearchTree{T}" /> contains a specific value. <code>Complexity: avg O(LogN), worst O(N)</code></summary>
77+
/// <summary>
78+
/// Determines whether the <see cref="BinarySearchTree{T}" /> contains a specific value.
79+
/// <code>Complexity: avg O(LogN), worst O(N)</code>
80+
/// </summary>
6781
/// <param name="value">The element to locate in the <see cref="BinarySearchTree{T}"/>.</param>
6882
/// <returns><c>true</c> if the <see cref="BinarySearchTree{T}"/> contains <paramref name="value"/>; <c>false</c> otherwise.</returns>
6983
public override bool Find(T value)
@@ -89,7 +103,10 @@ public override bool Find(T value)
89103
return false;
90104
}
91105

92-
/// <summary>Removes one occurrence of a specific element from the <see cref="BinarySearchTree{T}"/>. <code>Complexity: avg O(LogN), worst O(N)</code></summary>
106+
/// <summary>
107+
/// Removes one occurrence of a specific element from the <see cref="BinarySearchTree{T}"/>.
108+
/// <code>Complexity: avg O(LogN), worst O(N)</code>
109+
/// </summary>
93110
/// <param name="value">The element to remove from the <see cref="BinarySearchTree{T}"/>.</param>
94111
/// <returns><c>true</c> if the element was successfully removed from the <see cref="BinarySearchTree{T}"/>; <c>false</c> otherwise.</returns>
95112
public override bool Remove(T value)

0 commit comments

Comments
 (0)