forked from TheAlgorithms/C-Sharp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
RedBlackTreeNode.cs
60 lines (52 loc) · 1.53 KB
/
RedBlackTreeNode.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
namespace DataStructures.RedBlackTree;
/// <summary>
/// Enum to represent node colors.
/// </summary>
public enum NodeColor : byte
{
/// <summary>
/// Represents red node
/// </summary>
Red,
/// <summary>
/// Represents black node
/// </summary>
Black,
}
/// <summary>
/// Generic class to represent nodes in an <see cref="RedBlackTree{TKey}"/> instance.
/// </summary>
/// <typeparam name="TKey">The type of key for the node.</typeparam>
public class RedBlackTreeNode<TKey>
{
/// <summary>
/// Gets or sets key value of node.
/// </summary>
public TKey Key { get; set; }
/// <summary>
/// Gets or sets the color of the node.
/// </summary>
public NodeColor Color { get; set; }
/// <summary>
/// Gets or sets the parent of the node.
/// </summary>
public RedBlackTreeNode<TKey>? Parent { get; set; }
/// <summary>
/// Gets or sets left child of the node.
/// </summary>
public RedBlackTreeNode<TKey>? Left { get; set; }
/// <summary>
/// Gets or sets the right child of the node.
/// </summary>
public RedBlackTreeNode<TKey>? Right { get; set; }
/// <summary>
/// Initializes a new instance of the <see cref="RedBlackTreeNode{TKey}"/> class.
/// </summary>
/// <param name="key">Key value for node.</param>
/// <param name="parent">Parent of node.</param>
public RedBlackTreeNode(TKey key, RedBlackTreeNode<TKey>? parent)
{
Key = key;
Parent = parent;
}
}