Skip to content

Instantly share code, notes, and snippets.

@Acarus
Created May 23, 2015 17:32
Show Gist options
  • Save Acarus/5445ff8cb9a2fb151c00 to your computer and use it in GitHub Desktop.
Save Acarus/5445ff8cb9a2fb151c00 to your computer and use it in GitHub Desktop.
@Override
public boolean removeAll(Collection<?> c) {
for(Object item: c) {
int index = indexOf(item);
while(index >= 0) {
remove(index);
index = indexOf(item);
}
}
return true;
}
@Override
public boolean retainAll(Collection<?> c) {
Object[] arr = toArray();
for(Object item: arr) {
if(!c.contains(item)) {
int index = indexOf(item);
while(index >= 0) {
remove(index);
index = indexOf(item);
}
}
}
return true;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment