@Test
public void testRemove() {

    UpdateablePriorityQueue<MutableHolder<Integer>> queue = new UpdateablePriorityQueue<>(0);
    final MutableHolder<Integer> value = MutableHolder.of(3);
    UpdateablePriorityQueue.ElementRef ref = queue.add(value);
    final MutableHolder<Integer> four = MutableHolder.of(4);
    queue.add(four);
    final MutableHolder<Integer> five = MutableHolder.of(5);
    queue.add(five);
    final MutableHolder<Integer> six = MutableHolder.of(6);
    queue.add(six);
    MutableHolder<Integer> poll = queue.poll();
    Assert.assertEquals(value, poll);
    Assert.assertFalse(ref.remove());
    Iterator<MutableHolder<Integer>> iterator = queue.iterator();
    iterator.next();
    iterator.next();
    iterator.remove();
    iterator.next();
    Assert.assertFalse(iterator.hasNext());
    Assert.assertEquals(2, queue.size());
}