FlatFileBufferLinkedList implements NodeStateEntryList { public NodeStateEntry remove() { Preconditions.checkState(!isEmpty(), "Cannot remove item from empty list"); NodeStateEntry ret = head.next.data; head.next.isValid = false; head.next = head.next.next; size--; memUsage -= ret.estimatedMemUsage(); if (size == 0) { tail = head; } return ret; } FlatFileBufferLinkedList();  FlatFileBufferLinkedList(long memLimit); void add(@NotNull NodeStateEntry item); NodeStateEntry remove(); @Override Iterator<NodeStateEntry> iterator(); @Override int size(); @Override boolean isEmpty(); @Override long estimatedMemoryUsage(); @Override void close();  }
@Test public void remove() { try { list.remove(); fail("Must fail to remove from an empty list"); } catch (IllegalStateException ise) { } list.add(testNode("/")); assertEquals("Should get item on removal", testNode("/"), list.remove()); }