Left: | ||
Right: |
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 10 matching lines...) Expand all Loading... | |
21 import java.util.ArrayList; | 21 import java.util.ArrayList; |
22 import java.util.Collections; | 22 import java.util.Collections; |
23 import java.util.LinkedList; | 23 import java.util.LinkedList; |
24 import java.util.List; | 24 import java.util.List; |
25 | 25 |
26 /** | 26 /** |
27 * Helper methods related to {@link List}s. | 27 * Helper methods related to {@link List}s. |
28 * | 28 * |
29 * @author maxr@google.com (Max Ross) | 29 * @author maxr@google.com (Max Ross) |
30 */ | 30 */ |
31 public class Lists { | 31 public class Lists { |
Max Ross
2008/11/16 21:58:47
extra space
| |
32 | 32 |
33 private Lists() { } | 33 private Lists() { } |
34 | 34 |
35 /** | 35 /** |
36 * Construct a new {@link ArrayList}, taking advantage of type inference to | 36 * Construct a new {@link ArrayList}, taking advantage of type inference to |
37 * avoid specifying the type on the rhs. | 37 * avoid specifying the type on the rhs. |
38 */ | 38 */ |
39 public static <E> ArrayList<E> newArrayList() { | 39 public static <E> ArrayList<E> newArrayList() { |
40 return new ArrayList<E>(); | 40 return new ArrayList<E>(); |
41 } | 41 } |
42 | 42 |
43 /** | 43 /** |
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· | |
Max Ross
2008/11/16 21:58:47
Please provide a value for @return.
| |
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 |