Mercurial > hg > Members > tatsuki > TreeMap
changeset 4:3de906fb90d1
delete get
change getLoop -> get
author | tatsuki |
---|---|
date | Mon, 30 Mar 2015 12:58:27 +0900 |
parents | 090acf24fd3d |
children | 6928ef8ba6f0 |
files | src/main/java/jp/ac/u_ryukyu/ie/cr/tatsuki/TreeMap/Node.java src/main/java/jp/ac/u_ryukyu/ie/cr/tatsuki/TreeMap/TreeMap.java src/main/java/jp/ac/u_ryukyu/ie/cr/tatsuki/test/TreeMapTest.java |
diffstat | 3 files changed, 2 insertions(+), 22 deletions(-) [+] |
line wrap: on
line diff
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/tatsuki/TreeMap/Node.java Sun Mar 29 23:21:19 2015 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/tatsuki/TreeMap/Node.java Mon Mar 30 12:58:27 2015 +0900 @@ -31,22 +31,6 @@ public Optional<V> get(Comparable<? super K> key) { - int result = key.compareTo(getKey()); - - if (result > 0) - return right().get(key); - - else if (result < 0) - return left().get(key); - - else if (result == 0) - return Optional.ofNullable(getValue()); - - return Optional.ofNullable(null); - } - - public Optional<V> getLoop(Comparable<? super K> key) { - Node<K, V> cur = this; while (cur.exitNode()) {
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/tatsuki/TreeMap/TreeMap.java Sun Mar 29 23:21:19 2015 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/tatsuki/TreeMap/TreeMap.java Mon Mar 30 12:58:27 2015 +0900 @@ -14,7 +14,7 @@ int size; public TreeMap() { - this.root = new EmptyNode<>(); + this.root = new EmptyNode(); this.size = 0; } @@ -32,10 +32,6 @@ return root.get((Comparable<? super K>) key); } - public Optional<V> getLoop(K key) { - return root.getLoop((Comparable<? super K>) key); - } - public TreeMap put(K key, V value) { if (key == null || value == null) // null check
--- a/src/main/java/jp/ac/u_ryukyu/ie/cr/tatsuki/test/TreeMapTest.java Sun Mar 29 23:21:19 2015 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/tatsuki/test/TreeMapTest.java Mon Mar 30 12:58:27 2015 +0900 @@ -22,7 +22,7 @@ for (int count = 100; count > -10; count--) { - Optional<Integer> op = map.getLoop(count); + Optional<Integer> op = map.get(count); if (op.isPresent()) System.out.println(op.get()); }