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