1
#region Using directives
4
using System.Collections;
5
using System.Collections.Generic;
13
/// The BinaryTreeNode class represents a node in a binary tree, or a binary search tree.
14
/// It has precisely two neighbors, which can be accessed via the Left and Right properties.
16
/// <typeparam name="T">The type of data stored in the binary tree node.</typeparam>
17
public class BinaryTreeNode<T> : Node<T>
20
public BinaryTreeNode() : base() {}
21
public BinaryTreeNode(T data) : base(data, null) {}
22
public BinaryTreeNode(T data, BinaryTreeNode<T> left, BinaryTreeNode<T> right)
25
NodeList<T> children = new NodeList<T>(2);
29
base.Neighbors = children;
33
#region Public Properties
34
public BinaryTreeNode<T> Left
38
if (base.Neighbors == null)
41
return (BinaryTreeNode<T>) base.Neighbors[0];
45
if (base.Neighbors == null)
46
base.Neighbors = new NodeList<T>(2);
48
base.Neighbors[0] = value;
52
public BinaryTreeNode<T> Right
56
if (base.Neighbors == null)
59
return (BinaryTreeNode<T>) base.Neighbors[1];
63
if (base.Neighbors == null)
64
base.Neighbors = new NodeList<T>(2);
66
base.Neighbors[1] = value;