@Test public void removeAfter() { GroupConfigEntryList list = new GroupConfigEntryList(); list.add(new AddNodeEntry(1, 1, Collections.<NodeEndpoint>emptySet(), new NodeEndpoint("A", "localhost", 2333))); list.add(new AddNodeEntry(4, 1, Collections.<NodeEndpoint>emptySet(), new NodeEndpoint("A", "localhost", 2333))); list.add(new AddNodeEntry(10, 1, Collections.<NodeEndpoint>emptySet(), new NodeEndpoint("A", "localhost", 2333))); GroupConfigEntry firstRemovedEntry = list.removeAfter(3); Assert.assertEquals(4, firstRemovedEntry.getIndex()); GroupConfigEntry lastEntry = list.getLast(); Assert.assertEquals(1, lastEntry.getIndex()); }
public GroupConfigEntry removeAfter(int entryIndex) { Iterator<GroupConfigEntry> iterator = entries.iterator(); GroupConfigEntry firstRemovedEntry = null; while (iterator.hasNext()) { GroupConfigEntry entry = iterator.next(); if (entry.getIndex() > entryIndex) { if (firstRemovedEntry == null) { firstRemovedEntry = entry; } iterator.remove(); } } return firstRemovedEntry; }
GroupConfigEntryList implements Iterable<GroupConfigEntry> { public GroupConfigEntry removeAfter(int entryIndex) { Iterator<GroupConfigEntry> iterator = entries.iterator(); GroupConfigEntry firstRemovedEntry = null; while (iterator.hasNext()) { GroupConfigEntry entry = iterator.next(); if (entry.getIndex() > entryIndex) { if (firstRemovedEntry == null) { firstRemovedEntry = entry; } iterator.remove(); } } return firstRemovedEntry; } }
GroupConfigEntryList implements Iterable<GroupConfigEntry> { public GroupConfigEntry removeAfter(int entryIndex) { Iterator<GroupConfigEntry> iterator = entries.iterator(); GroupConfigEntry firstRemovedEntry = null; while (iterator.hasNext()) { GroupConfigEntry entry = iterator.next(); if (entry.getIndex() > entryIndex) { if (firstRemovedEntry == null) { firstRemovedEntry = entry; } iterator.remove(); } } return firstRemovedEntry; }  }
GroupConfigEntryList implements Iterable<GroupConfigEntry> { public GroupConfigEntry removeAfter(int entryIndex) { Iterator<GroupConfigEntry> iterator = entries.iterator(); GroupConfigEntry firstRemovedEntry = null; while (iterator.hasNext()) { GroupConfigEntry entry = iterator.next(); if (entry.getIndex() > entryIndex) { if (firstRemovedEntry == null) { firstRemovedEntry = entry; } iterator.remove(); } } return firstRemovedEntry; }  GroupConfigEntry getLast(); void add(GroupConfigEntry entry); GroupConfigEntry removeAfter(int entryIndex); List<GroupConfigEntry> subList(int fromIndex, int toIndex); @Override @Nonnull Iterator<GroupConfigEntry> iterator(); @Override String toString(); }
GroupConfigEntryList implements Iterable<GroupConfigEntry> { public GroupConfigEntry removeAfter(int entryIndex) { Iterator<GroupConfigEntry> iterator = entries.iterator(); GroupConfigEntry firstRemovedEntry = null; while (iterator.hasNext()) { GroupConfigEntry entry = iterator.next(); if (entry.getIndex() > entryIndex) { if (firstRemovedEntry == null) { firstRemovedEntry = entry; } iterator.remove(); } } return firstRemovedEntry; }  GroupConfigEntry getLast(); void add(GroupConfigEntry entry); GroupConfigEntry removeAfter(int entryIndex); List<GroupConfigEntry> subList(int fromIndex, int toIndex); @Override @Nonnull Iterator<GroupConfigEntry> iterator(); @Override String toString();  }