java - Remove multiple elements from ArrayList -


i have bunch of indexes , want remove elements @ these indexes arraylist. can't simple sequence of remove()s because elements shifted after each removal. how solve this?

sort indices in descending order , remove them 1 one. if that, there's no way remove affect indices later want remove.

how sort them depend on collection using store indices. if it's list, can this:

list<integer> indices; collections.sort(indices, new comparator<integer>() {    public int compare(integer a, integer b) {       //todo: handle null       return b.compareto(a);    } } 

edit

@aioobe found helper failed find. instead of above, can use

collections.sort(indices, collections.reverseorder()); 

Comments

Popular posts from this blog

python - Scipy curvefit RuntimeError:Optimal parameters not found: Number of calls to function has reached maxfev = 1000 -

c# - How to add a new treeview at the selected node? -

java - netbeans "Please wait - classpath scanning in progress..." -