Exemple #1
0
 public BTreeNode Add(int value)
 {
     if (Head == null)
     {
         return Head = new BTreeNode() {Value = value};
     }
     return Head.Add(Head, value);
 }
Exemple #2
0
 public BTreeNode Find(BTreeNode current, int value)
 {
     if (current == null) return null;
     if (current.Value == value) return current;
     if (value < current.Value) return Find(current.Left, value);
     return Find(current.Right, value);
 }
Exemple #3
0
 public void MoveUp()
 {
     _currentRow--;
     if (_currentNode.Parent.Right != null)
     {
         if (_currentNode.Parent.Right.Value == _currentNode.Value)
         {
             _currentCol--;
         }
     }
     _currentNode = _currentNode.Parent;
 }
Exemple #4
0
 public void MoveRight()
 {
     _currentRow++;
     _currentCol++;
     _currentNode = _currentNode.Right;
 }
Exemple #5
0
 public void MoveLeft()
 {
     _currentRow++;
     _currentNode = _currentNode.Left;
 }
Exemple #6
0
 public BTreeNodeMapper(BTreeNode node)
 {
     _currentNode = node;
     _currentCol = 1;
     _currentRow = 1;
 }
Exemple #7
0
 public BTreeNode Add(BTreeNode current, int value)
 {
     if (current.Value == value)
     {
         return current;
     }
     if (value < current.Value)
     {
         if (current.Left == null)
         {
             current.Left = new BTreeNode() {Value = value};
             current.Left.Parent = current;
             return current.Left;
         }
         else
         {
             Add(current.Left, value);
         }
     }
     if (value > current.Value)
     {
         if (current.Right == null)
         {
             current.Right = new BTreeNode() { Value = value };
             current.Right.Parent = current;
             return current.Right;
         }
         else
         {
             Add(current.Right, value);
         }
     }
     return null;
 }