OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 package org.chromium.base; | 5 package org.chromium.base; |
6 | 6 |
7 import java.util.ArrayList; | 7 import java.util.ArrayList; |
8 import java.util.Collections; | 8 import java.util.Collections; |
9 import java.util.HashSet; | 9 import java.util.HashSet; |
10 | 10 |
(...skipping 13 matching lines...) Expand all Loading... |
24 return set; | 24 return set; |
25 } | 25 } |
26 | 26 |
27 @SafeVarargs | 27 @SafeVarargs |
28 public static <E> ArrayList<E> newArrayList(E... elements) { | 28 public static <E> ArrayList<E> newArrayList(E... elements) { |
29 ArrayList<E> list = new ArrayList<E>(elements.length); | 29 ArrayList<E> list = new ArrayList<E>(elements.length); |
30 Collections.addAll(list, elements); | 30 Collections.addAll(list, elements); |
31 return list; | 31 return list; |
32 } | 32 } |
33 | 33 |
| 34 @VisibleForTesting |
34 public static <E> ArrayList<E> newArrayList(Iterable<E> iterable) { | 35 public static <E> ArrayList<E> newArrayList(Iterable<E> iterable) { |
35 ArrayList<E> list = new ArrayList<E>(); | 36 ArrayList<E> list = new ArrayList<E>(); |
36 for (E element : iterable) { | 37 for (E element : iterable) { |
37 list.add(element); | 38 list.add(element); |
38 } | 39 } |
39 return list; | 40 return list; |
40 } | 41 } |
41 } | 42 } |
OLD | NEW |