# HG changeset patch # User tatsuki # Date 1441051478 -32400 # Node ID 9a410eddbfa487405f743a2b75495adf2ae97352 # Parent 1b3661be31195a3dc8bd654bf8e5fb9472522767 delete warning diff -r 1b3661be3119 -r 9a410eddbfa4 src/main/java/jp/ac/u_ryukyu/ie/cr/jungle/data/treemap/BlackNode.java --- a/src/main/java/jp/ac/u_ryukyu/ie/cr/jungle/data/treemap/BlackNode.java Tue Aug 11 08:16:07 2015 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/jungle/data/treemap/BlackNode.java Tue Sep 01 05:04:38 2015 +0900 @@ -83,8 +83,8 @@ return false; } - @Override + @SuppressWarnings("unchecked") public Node replaceNode(Node parent, Comparator ctr) throws RotateParent { Node newNode; if (!this.left().isNotEmpty() && !this.right().isNotEmpty()) { //自身を削除する @@ -115,7 +115,7 @@ return leftSubTreeNode.deleteBalance(newParent, ctr); } } else { - Node leftSubTreeNode = null; + Node leftSubTreeNode; try { leftSubTreeNode = this.left().replaceNode(this, ctr);//右の子がいなかった場合、左の子を昇格させるだけで良い。 return createNode(this.left().getKey(), this.left().getValue(), leftSubTreeNode, this.right()); diff -r 1b3661be3119 -r 9a410eddbfa4 src/main/java/jp/ac/u_ryukyu/ie/cr/jungle/data/treemap/DefaultComparator.java --- a/src/main/java/jp/ac/u_ryukyu/ie/cr/jungle/data/treemap/DefaultComparator.java Tue Aug 11 08:16:07 2015 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/jungle/data/treemap/DefaultComparator.java Tue Sep 01 05:04:38 2015 +0900 @@ -2,11 +2,9 @@ import java.util.Comparator; -/** - * Created by e115731 on 15/08/10. - */ public class DefaultComparator implements Comparator{ @Override + @SuppressWarnings("unchecked") public int compare(K key, K compareKey) { return ((Comparable)key).compareTo(compareKey); } diff -r 1b3661be3119 -r 9a410eddbfa4 src/main/java/jp/ac/u_ryukyu/ie/cr/jungle/data/treemap/Node.java --- a/src/main/java/jp/ac/u_ryukyu/ie/cr/jungle/data/treemap/Node.java Tue Aug 11 08:16:07 2015 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/jungle/data/treemap/Node.java Tue Sep 01 05:04:38 2015 +0900 @@ -79,6 +79,7 @@ } + @SuppressWarnings("unchecked") public Node delete(K key, Node parent, Comparator ctr, Rotate side) throws RotateParent { if (this.isNotEmpty()) { int result = compare(key, ctr); @@ -120,7 +121,7 @@ return null; // no key } - + @SuppressWarnings("unchecked") public Node deleteSubTreeMaxNode(Node parent, Comparator ctr, Rotate side) throws RotateParent { Node node; try { diff -r 1b3661be3119 -r 9a410eddbfa4 src/main/java/jp/ac/u_ryukyu/ie/cr/jungle/data/treemap/RedNode.java --- a/src/main/java/jp/ac/u_ryukyu/ie/cr/jungle/data/treemap/RedNode.java Tue Aug 11 08:16:07 2015 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/jungle/data/treemap/RedNode.java Tue Sep 01 05:04:38 2015 +0900 @@ -55,6 +55,7 @@ return true; } + @SuppressWarnings("unchecked") @Override public Node replaceNode(Node parent, Comparator ctr) throws RotateParent { Node newNode; diff -r 1b3661be3119 -r 9a410eddbfa4 src/main/java/jp/ac/u_ryukyu/ie/cr/jungle/data/treemap/RotateParent.java --- a/src/main/java/jp/ac/u_ryukyu/ie/cr/jungle/data/treemap/RotateParent.java Tue Aug 11 08:16:07 2015 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/jungle/data/treemap/RotateParent.java Tue Sep 01 05:04:38 2015 +0900 @@ -1,5 +1,8 @@ package jp.ac.u_ryukyu.ie.cr.jungle.data.treemap; +/** + * Generic Exception not support + **/ public class RotateParent extends Exception { Node parent; @@ -10,4 +13,4 @@ public Node getParent() { return parent; } -} +} \ No newline at end of file diff -r 1b3661be3119 -r 9a410eddbfa4 src/main/java/jp/ac/u_ryukyu/ie/cr/jungle/data/treemap/TreeMap.java --- a/src/main/java/jp/ac/u_ryukyu/ie/cr/jungle/data/treemap/TreeMap.java Tue Aug 11 08:16:07 2015 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/ie/cr/jungle/data/treemap/TreeMap.java Tue Sep 01 05:04:38 2015 +0900 @@ -11,7 +11,7 @@ public class TreeMap { final Node root; - Comparator comparator; + final Comparator comparator; public TreeMap() { this.root = new EmptyNode<>(); @@ -33,20 +33,15 @@ } public Optional get(final K key) { - return root.get(key, comparator); + return root.get(key, this.comparator); } public TreeMap put(K key, V value) { - - if (key == null || value == null) // null check - throw new NullPointerException(); - if (isEmpty()) { Node newRoot = new BlackNode<>(key, value, new EmptyNode<>(), new EmptyNode<>()); return new TreeMap<>(newRoot, this.comparator); } - - Node newEntry = root.put(key, value, comparator); + Node newEntry = root.put(key, value, this.comparator); Node newRoot = new BlackNode<>(newEntry.getKey(), newEntry.getValue(), newEntry.left(), newEntry.right()); return new TreeMap<>(newRoot, this.comparator); }