Home | History | Annotate | Download | only in collect

Lines Matching refs:list

32 import java.util.List;
43 * Static utility methods pertaining to {@link List} instances. Also see this
76 * @param elements the elements that the list should contain, in order
84 ArrayList<E> list = new ArrayList<E>(capacity);
85 Collections.addAll(list, elements);
86 return list;
103 * @param elements the elements that the list should contain, in order
126 * @param elements the elements that the list should contain, in order
132 ArrayList<E> list = newArrayList();
134 list.add(elements.next());
136 return list;
144 * <p><b>Note:</b> if you know the exact size your list will be, consider
145 * using a fixed-size list ({@link Arrays#asList(Object[])}) or an {@link
149 * the list, consider padding this estimate by a suitable amount, or simply
153 * the returned array list ({@code ArrayList} documentation calls this
170 * <p><b>Note:</b> If you know the <i>exact</i> number of elements the list
174 * @param estimatedSize an estimate of the eventual {@link List#size()} of
175 * the new list
191 * <p><b>Note:</b> if you need an immutable empty {@link List}, use
204 * @param elements the elements that the list should contain, in order
210 LinkedList<E> list = newLinkedList();
212 list.add(element);
214 return list;
218 * Returns an unmodifiable list containing the specified first element and
220 * rest} array will be reflected in the returned list. Unlike {@link
221 * Arrays#asList}, the returned list is unmodifiable.
227 * <p>The returned list is serializable and implements {@link RandomAccess}.
231 * @return an unmodifiable list containing the specified elements
233 public static <E> List<E> asList(@Nullable E first, E[] rest) {
259 * Returns an unmodifiable list containing the specified first and second
261 * to the {@code rest} array will be reflected in the returned list. Unlike
262 * {@link Arrays#asList}, the returned list is unmodifiable.
268 * <p>The returned list is serializable and implements {@link RandomAccess}.
273 * @return an unmodifiable list containing the specified elements
275 public static <E> List<E> asList(
311 * Returns a list that applies {@code function} to each element of {@code
312 * fromList}. The returned list is a transformed view of {@code fromList};
313 * changes to {@code fromList} will be reflected in the returned list and vice
317 * items cannot be stored in the returned list. The {@code add},
319 * list.
322 * for the returned list to be a view, but it means that the function will be
323 * applied many times for bulk operations like {@link List#contains} and
324 * {@link List#hashCode}. For this to perform well, {@code function} should be
325 * fast. To avoid lazy evaluation when the returned list doesn't need to be a
326 * view, copy the returned list into a new list of your choosing.
329 * returned list. The returned list always implements {@link Serializable},
331 * {@code function} are serializable. The returned list is threadsafe if the
332 * supplied list and function are.
334 public static <F, T> List<T> transform(
335 List<F> fromList, Function<? super F, ? extends T> function) {
342 * Implementation of a sequential transforming list.
348 final List<F> fromList;
352 List<F> fromList, Function<? super F, ? extends T> function) {
359 * directly to the backing list.
412 * Implementation of a transforming random access list. We try to make as many
413 * of these methods pass-through to the source list as possible so that the
414 * performance characteristics of the source list and transformed list are
421 final List<F> fromList;
425 List<F> fromList, Function<? super F, ? extends T> function) {
448 * Returns consecutive {@linkplain List#subList(int, int) sublists} of a list,
449 * each of the same size (the final list may be smaller). For example,
450 * partitioning a list containing {@code [a, b, c, d, e]} with a partition
451 * size of 3 yields {@code [[a, b, c], [d, e]]} -- an outer list containing
454 * <p>The outer list is unmodifiable, but reflects the latest state of the
455 * source list. The inner lists are sublist views of the original list,
456 * produced on demand using {@link List#subList(int, int)}, and are subject
459 * @param list the list to return consecutive sublists of
462 * @return a list of consecutive sublists
465 public static <T> List<List<T>> partition(List<T> list, int size) {
466 checkNotNull(list);
468 return (list instanceof RandomAccess)
469 ? new RandomAccessPartition<T>(list, size)
470 : new Partition<T>(list, size);
473 private static class Partition<T> extends AbstractList<List<T>> {
474 final List<T> list;
477 Partition(List<T> list, int size) {
478 this.list = list;
482 @Override public List<T> get(int index) {
486 int end = Math.min(start + size, list.size());
487 return Platform.subList(list, start, end);
491 return (list.size() + size - 1) / size;
495 return list.isEmpty();
501 RandomAccessPartition(List<T> list, int size) {
502 super(list, size);