public class ListRemove<C>
extends java.lang.Object
List<C> list;
...
ListRemove<C> listRemove = new ListRemove<C>(list);
for (int i=0; i<list.size(); i++) {
if (item i should be removed) {
listRemove.remove (i);
}
}
listRemove.Remove(); // do the actual removal
...
listRemove.undo(); // undo the removal
Item to be removed are specified by index. The class attempts
to preform the remove in O(n) time.Constructor and Description |
---|
ListRemove(java.util.List<C> list) |
Modifier and Type | Method and Description |
---|---|
java.util.List<C> |
getList() |
java.util.ArrayList<C> |
getRemoved() |
void |
remove() |
void |
requestRemove(int idx) |
void |
requestRemoveAll(java.util.Collection<java.lang.Integer> idxs) |
boolean |
undo() |
public ListRemove(java.util.List<C> list)
public java.util.List<C> getList()
public java.util.ArrayList<C> getRemoved()
public void requestRemove(int idx)
public void requestRemoveAll(java.util.Collection<java.lang.Integer> idxs)
public void remove()
public boolean undo()