OLD | NEW |
1 /** | 1 /** |
2 * Copyright (C) 2007 Google Inc. | 2 * Copyright (C) 2007 Google Inc. |
3 * | 3 * |
4 * This library is free software; you can redistribute it and/or | 4 * This library is free software; you can redistribute it and/or |
5 * modify it under the terms of the GNU Lesser General Public | 5 * modify it under the terms of the GNU Lesser General Public |
6 * License as published by the Free Software Foundation; either | 6 * License as published by the Free Software Foundation; either |
7 * version 2.1 of the License, or (at your option) any later version. | 7 * version 2.1 of the License, or (at your option) any later version. |
8 | 8 |
9 * This library is distributed in the hope that it will be useful, | 9 * This library is distributed in the hope that it will be useful, |
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 * Construct a new {@link ArrayList} with the specified capacity, taking advan
tage of type inference to | 44 * Construct a new {@link ArrayList} with the specified capacity, taking advan
tage of type inference to |
45 * avoid specifying the type on the rhs. | 45 * avoid specifying the type on the rhs. |
46 */ | 46 */ |
47 public static <E> ArrayList<E> newArrayListWithCapacity(int initialCapacity) { | 47 public static <E> ArrayList<E> newArrayListWithCapacity(int initialCapacity) { |
48 return new ArrayList<E>(initialCapacity); | 48 return new ArrayList<E>(initialCapacity); |
49 } | 49 } |
50 | 50 |
51 /** | 51 /** |
52 * Construct a new {@link ArrayList} with the provided elements, taking advant
age of type inference to | 52 * Construct a new {@link ArrayList} with the provided elements, taking advant
age of type inference to |
53 * avoid specifying the type on the rhs. | 53 * avoid specifying the type on the rhs. |
| 54 * @param elements a collection of elements, to be used to populate the lists |
| 55 * @return an ArrayList<E> containg all of the given elements· |
54 */ | 56 */ |
55 public static <E> ArrayList<E> newArrayList(E... elements) { | 57 public static <E> ArrayList<E> newArrayList(E... elements) { |
56 ArrayList<E> set = newArrayList(); | 58 ArrayList<E> set = newArrayList(); |
57 Collections.addAll(set, elements); | 59 Collections.addAll(set, elements); |
58 return set; | 60 return set; |
59 } | 61 } |
60 | 62 |
61 /** | 63 /** |
62 * Construct a new {@link ArrayList} with the contents of the provided {@link
Iterable}, taking advantage of type inference to | 64 * Construct a new {@link ArrayList} with the contents of the provided {@link
Iterable}, taking advantage of type inference to |
63 * avoid specifying the type on the rhs. | 65 * avoid specifying the type on the rhs. |
64 */ | 66 */ |
65 public static <E> ArrayList<E> newArrayList(Iterable<? extends E> elements) { | 67 public static <E> ArrayList<E> newArrayList(Iterable<? extends E> elements) { |
66 ArrayList<E> list = newArrayList(); | 68 ArrayList<E> list = newArrayList(); |
67 for(E e : elements) { | 69 for(E e : elements) { |
68 list.add(e); | 70 list.add(e); |
69 } | 71 } |
70 return list; | 72 return list; |
71 } | 73 } |
72 | 74 |
73 /** | 75 /** |
74 * Construct a new {@link LinkedList}, taking advantage of type inference to | 76 * Construct a new {@link LinkedList}, taking advantage of type inference to |
75 * avoid specifying the type on the rhs. | 77 * avoid specifying the type on the rhs. |
76 */ | 78 */ |
77 public static <E> LinkedList<E> newLinkedList() { | 79 public static <E> LinkedList<E> newLinkedList() { |
78 return new LinkedList<E>(); | 80 return new LinkedList<E>(); |
79 } | 81 } |
80 } | 82 } |
OLD | NEW |