Corrections for LookupTree.

This commit is contained in:
asofold 2012-09-03 02:55:47 +02:00
parent 0915725410
commit 3e56b95c02

View File

@ -26,7 +26,7 @@ public class LookupTree<K, N extends Node<K>>{
public Node<K> getChild(final K key, final NodeFactory<K, Node<K>> factory){ public Node<K> getChild(final K key, final NodeFactory<K, Node<K>> factory){
if (children == null){ if (children == null){
if (factory != null) children = new HashMap<K, Node<K>>(); if (factory != null) children = new HashMap<K, Node<K>>(3);
else return null; else return null;
} }
Node<K> node = children.get(key); Node<K> node = children.get(key);
@ -108,9 +108,12 @@ public class LookupTree<K, N extends Node<K>>{
depth ++; depth ++;
} }
} }
if (create || insertion.isEnd && depth == keys.size()){ if (create){
node = current;
current.isEnd = true;
}
else if (depth == keys.size()){
node = current; node = current;
if (insertion != current) current.isEnd = true;
} }
return new LookupEntry<K, N>(node, insertion, depth); return new LookupEntry<K, N>(node, insertion, depth);
} }