@Override public void remove() { list.remove(next.prev); } }
private final void remove(int elementId, int rankIdx) { buckets[rankIdx].remove(handles[elementId]); size--; }
/** * Updates the priority of the given queue item from the oldPriority to the newPriority. * <p /> * NOTE: The given {@link MaterialRequestObject} must be in the queue with the given oldPriority! There will be no checks! * * @param oldPriority * @param newPriority * @param materialRequest */ final void updatePriority(EPriority oldPriority, EPriority newPriority, MaterialRequestObject materialRequest) { EBuildingType buildingType = materialRequest.getBuildingType(); getQueue(oldPriority, buildingType).remove(materialRequest); getQueue(newPriority, buildingType).pushFront(materialRequest); // TODO @Andreas Eberle: check if this should be pushEnd() }
@Test public void testRemoveByHandle() { DoubleLinkedIntListItem handles[] = new DoubleLinkedIntListItem[TEST_NUMBERS]; for (int i = 0; i < TEST_NUMBERS; i++) { handles[i] = new DoubleLinkedIntListItem(i); list.pushFront(handles[i]); } list.remove(handles[4]); list.remove(handles[7]); assertEquals("incorrect size after removing 2 values", TEST_NUMBERS - 2, list.size()); assertNull("the removed item should not hold a 'next' reference", handles[4].next); assertNull("the removed item should not hold a 'prev' reference", handles[4].prev); assertNull("the removed item should not hold a 'next' reference", handles[7].next); assertNull("the removed item should not hold a 'prev' reference", handles[7].prev); for (int i = TEST_NUMBERS - 1; i >= 0; i--) { if (i == 4 || i == 7) { // skip the removed values continue; } assertEquals(i, list.popFront().value); } assertEquals("incorrect size after popFront all values", 0, list.size()); }