This commit is contained in:
Alexey Andreev 2015-05-14 18:11:47 +04:00
parent 07b65a92c7
commit 639633018e
2 changed files with 17 additions and 2 deletions

View File

@ -363,9 +363,9 @@ public class TTreeMap<K, V> extends TAbstractMap<K, V> implements TCloneable, TS
while (minDepth > 0) { while (minDepth > 0) {
TreeNode<K, V> node = pathToMin[--minDepth]; TreeNode<K, V> node = pathToMin[--minDepth];
node.left = right; node.left = right;
right = node;
node.fix(); node.fix();
node.balance(); node = node.balance();
right = node;
} }
min.right = right; min.right = right;
min.left = left; min.left = left;

View File

@ -639,4 +639,19 @@ public class TreeMapTest {
} }
return treeMap; return treeMap;
} }
@Test
public void deletesProperly() {
TreeMap<Integer, Integer> tm = new TreeMap<>();
for (int i = 0; i <= 100; ++i) {
tm.put(i, i);
}
for (int i = 0; i <= 100; ++i) {
Integer removed = tm.remove(i);
assertEquals(Integer.valueOf(i), removed);
tm.put(i, i + 1);
assertTrue("13 is expected to be in the map: " + i, tm.containsKey(13));
assertTrue("99 is expected to be in the map: " + i, tm.containsKey(99));
}
}
} }