@Test
public void testRemove()
{
int limit = 100;
IntList values = new IntArrayList(new int[] {
1, 20, 1000, 2, 3, 30, 40, 10, 11, 12, 13, 300, 400, 500, 600
});
ByteBuffer myBuffer = ByteBuffer.allocate(1000000);
ByteBufferMinMaxOffsetHeap heap = new ByteBufferMinMaxOffsetHeap(myBuffer, limit, Ordering.natural(), null);
for (Integer value : values) {
heap.addOffset(value);
Assert.assertTrue(heap.isIntact());
}
heap.removeOffset(12);
Assert.assertTrue(heap.isIntact());
Collections.sort(values);
values.rem(12);
List<Integer> actual = new ArrayList<>();
for (int i = 0; i < values.size(); i++) {
int min = heap.removeMin();
actual.add(min);
}
Assert.assertEquals(values, actual);
}