35
|
1 using System.Collections.Generic;
|
20
|
2
|
35
|
3 public class EmptyNode<K, V> : TreeMapNode<K, V>
|
|
4 {
|
20
|
5 //static V values;
|
|
6 // Use this for initialization
|
35
|
7 public EmptyNode()
|
|
8 : base(default(K), default(V))
|
20
|
9 {
|
|
10 }
|
|
11
|
35
|
12 public EmptyNode(K key)
|
|
13 : base(key, default(V))
|
20
|
14 {
|
|
15 }
|
|
16
|
35
|
17 public override TreeMapNode<K, V> lefts()
|
|
18 {
|
|
19 return new EmptyNode<K, V>();
|
20
|
20 }
|
|
21
|
35
|
22 public override TreeMapNode<K, V> rights()
|
|
23 {
|
|
24 return new EmptyNode<K, V>();
|
20
|
25 }
|
|
26
|
35
|
27 public override bool isNotEmpty()
|
|
28 {
|
20
|
29 return false;
|
|
30 }
|
|
31
|
35
|
32 public override TreeMapNode<K, V> createNode(K key, V value, TreeMapNode<K, V> left, TreeMapNode<K, V> right)
|
|
33 {
|
|
34 return new RedNode<K, V>(key, value, new EmptyNode<K, V>(), new EmptyNode<K, V>());
|
20
|
35 }
|
|
36
|
35
|
37 public TreeMapNode<K, V> put(K k, V value)
|
|
38 {
|
|
39 return new RedNode<K, V>(k, value, new EmptyNode<K, V>(), new EmptyNode<K, V>());
|
20
|
40 }
|
|
41
|
|
42 //I don't know only Comparator method.
|
35
|
43 public override rebuildNode<K, V> replaceNode(TreeMapNode<K, V> parent, Comparer<K> ctr)
|
|
44 { // not use method
|
|
45 return new rebuildNode<K, V>(false, this);
|
20
|
46 }
|
|
47
|
35
|
48 public override rebuildNode<K, V> deleteNode()
|
|
49 {
|
|
50 return new rebuildNode<K, V>(false, this);
|
20
|
51 }
|
35
|
52
|
|
53 public override TreeMapNode<K, V> insBalance()
|
|
54 {
|
20
|
55 return insBalance();
|
|
56 }
|
|
57
|
35
|
58 public override Rotate checkRotate(Rotate side)
|
|
59 {
|
20
|
60 return Rotate.N;
|
|
61 }
|
|
62
|
35
|
63 public override bool isRed()
|
|
64 {
|
20
|
65 return false;
|
|
66 }
|
|
67
|
35
|
68 public override int checkDepth(int count, int minCount)
|
|
69 { // test method
|
|
70 if (count < minCount || minCount == 0)
|
|
71 {
|
20
|
72 minCount = count;
|
|
73 }
|
35
|
74 //c# is there assert??
|
|
75 //Assert.assertTrue(count <= 2 * minCount);
|
20
|
76 return minCount;
|
|
77 }
|
|
78
|
|
79 }
|