List of usage examples for java.util.concurrent CopyOnWriteArrayList set
public E set(int index, E element)
From source file:Main.java
/** * Sort the CopyOnWriteArrayList.// www . j a v a 2 s.c om * * @param list The list to sort. * @param <E> The type of data. */ public static <E extends Comparable<E>> void sort(CopyOnWriteArrayList<E> list) { Object[] content = list.toArray(); Arrays.sort(content); for (int i = 0; i < content.length; i++) { list.set(i, (E) content[i]); } }
From source file:Main.java
/** * Sort the CopyOnWriteArrayList using the given comparator. * * @param list The list to sort./*from ww w. j av a 2 s. c o m*/ * @param comparator The comparator to use. * @param <E> The type of data. */ public static <E> void sort(CopyOnWriteArrayList<E> list, Comparator<E> comparator) { Object[] content = list.toArray(); Arrays.sort(content, (Comparator) comparator); for (int i = 0; i < content.length; i++) { list.set(i, (E) content[i]); } }