Mercurial > hg > Database > jungle-sharp
comparison src/main/csharp/jp.ac.u-ryukyu.ie.cr/jungle/data/treemap/TreeMapNode.cs @ 2:a3af05a061b4
fix , but not work.
author | Kazuma |
---|---|
date | Fri, 01 Jul 2016 19:28:57 +0900 |
parents | 5c58219da97e |
children | 224f0f8b4f40 |
comparison
equal
deleted
inserted
replaced
1:5c58219da97e | 2:a3af05a061b4 |
---|---|
5 | 5 |
6 | 6 |
7 public abstract class TreeMapNode<K,V> | 7 public abstract class TreeMapNode<K,V> |
8 { | 8 { |
9 | 9 |
10 public K key = default(K); | 10 protected K key = default(K); |
11 public V value = default(V); | 11 protected V value = default(V); |
12 public TreeMapNode<K,V> right; | 12 public TreeMapNode<K,V> right; |
13 public TreeMapNode<K,V> left; | 13 public TreeMapNode<K,V> left; |
14 | 14 |
15 | 15 |
16 // Use this for initialization | 16 // Use this for initialization |
40 } | 40 } |
41 | 41 |
42 public V get (K key, Comparer<K> ctr) | 42 public V get (K key, Comparer<K> ctr) |
43 { | 43 { |
44 TreeMapNode<K,V> cur = this; | 44 TreeMapNode<K,V> cur = this; |
45 int result = cur.compare (key, ctr); | 45 while (cur.isNotEmpty ()) { // getでEmpty nodeを返している ? compareでKeyが0になっている |
46 while (cur.isNotEmpty ()) { | 46 int result = cur.compare (key, ctr); |
47 if (result > 0) { | 47 if (result > 0) { |
48 cur = cur.rights (); | 48 cur = cur.rights (); |
49 } else if (result < 0) { | 49 } else if (result < 0) { |
50 cur = cur.lefts (); | 50 cur = cur.lefts (); |
51 } else if (result == 0) { | 51 } else if (result == 0) { |
52 if (cur != null) { | 52 if (cur != null) { |
53 return cur.getValue (); | 53 return cur.getValue (); |
54 } | 54 } |
55 } | 55 } |
56 } | 56 } |
57 return default(V); // Optional<V>.ofNullable (null); | 57 return default(V); |
58 } | 58 } |
59 | 59 |
60 | 60 |
61 | 61 |
62 public virtual TreeMapNode<K,V> rights () { | 62 public virtual TreeMapNode<K,V> rights () { |