@Test public void removeFromOneElementTree() { tree = new BTree<Integer>(); tree.add(1); tree.remove(1); assertThat(tree.size(), is(0)); }
@Test public void removeElement2() { tree.remove(2); assertThat(tree.size(), is(5)); List<Integer> list = tree.preorder(); List<Integer> expected = Arrays.asList(3, 1, 5, 4, 6); assertThat(list, is(equalTo(expected))); }
private void remove(long startValue, long increment, int valueCount) throws IOException { long value = startValue; byte[] data = new byte[8]; for (int i = 0; i < valueCount; i++) { ByteArrayUtil.putLong(value, data, 0); btree.remove(data); value += increment; } }
@Test public void removeANotFoundElement() { tree.remove(0); assertThat(tree.size(), is(6)); List<Integer> list = tree.preorder(); List<Integer> expected = Arrays.asList(2, 1, 4, 3, 5, 6); assertThat(list, is(equalTo(expected))); }
private void update(long startValue, long increment, int valueCount, long updateDelta) throws IOException { long oldValue = startValue; long newValue; byte[] oldData = new byte[8]; byte[] newData = new byte[8]; for (int i = 0; i < valueCount; i++) { newValue = oldValue += updateDelta; ByteArrayUtil.putLong(oldValue, oldData, 0); ByteArrayUtil.putLong(newValue, newData, 0); btree.insert(newData); btree.remove(oldData); oldValue += increment; } }