Here you can find the source of removeAll(List
Parameter | Description |
---|---|
list | the list to remove elements from. |
indexes | the indexes for the elements to remove. |
public static <T> void removeAll(List<T> list, List<Integer> indexes)
//package com.java2s; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.List; public class Main { /**/*from ww w.j a v a 2 s .co m*/ * Removes from the given list the elements at the given indexes. * * @param list the list to remove elements from. * @param indexes the indexes for the elements to remove. */ public static <T> void removeAll(List<T> list, List<Integer> indexes) { if (list == null || indexes == null) { return; } Collections.sort(indexes, Collections.reverseOrder()); for (Integer index : indexes) { list.remove((int) index); } } /** * Removes from the given list the elements at the given indexes. * * @param indexes the list to remove elements from. * @param indexes the indexes for the elements to remove. */ public static <T> void removeAll(List<T> list, Integer... indexes) { List<Integer> inx = new ArrayList<Integer>(Arrays.asList(indexes)); removeAll(list, inx); } }