Lines Matching refs:elements

38  * Does not permit null elements.
65 // Casting to any type is safe because the list will never hold any elements.
84 * Returns an immutable list containing the given elements, in order.
93 * Returns an immutable list containing the given elements, in order.
102 * Returns an immutable list containing the given elements, in order.
111 * Returns an immutable list containing the given elements, in order.
120 * Returns an immutable list containing the given elements, in order.
129 * Returns an immutable list containing the given elements, in order.
139 * Returns an immutable list containing the given elements, in order.
149 * Returns an immutable list containing the given elements, in order.
159 * Returns an immutable list containing the given elements, in order.
169 * Returns an immutable list containing the given elements, in order.
182 * Returns an immutable list containing the given elements, in order.
208 * Returns an immutable list containing the given elements, in order. If
209 * {@code elements} is a {@link Collection}, this method behaves exactly as
211 * copyOf(elements.iterator()}.
213 * @throws NullPointerException if any of {@code elements} is null
215 public static <E> ImmutableList<E> copyOf(Iterable<? extends E> elements) {
216 checkNotNull(elements); // TODO(kevinb): is this here only for GWT?
217 return (elements instanceof Collection)
218 ? copyOf(Collections2.cast(elements))
219 : copyOf(elements.iterator());
223 * Returns an immutable list containing the given elements, in order.
235 * <p>This method is safe to use even when {@code elements} is a synchronized
239 * @throws NullPointerException if any of {@code elements} is null
241 public static <E> ImmutableList<E> copyOf(Collection<? extends E> elements) {
242 if (elements instanceof ImmutableCollection) {
244 ImmutableList<E> list = ((ImmutableCollection<E>) elements).asList();
247 return copyFromCollection(elements);
251 * Returns an immutable list containing the given elements, in order.
253 * @throws NullPointerException if any of {@code elements} is null
255 public static <E> ImmutableList<E> copyOf(Iterator<? extends E> elements) {
256 return copyFromCollection(Lists.newArrayList(elements));
260 * Returns an immutable list containing the given elements, in order.
262 * @throws NullPointerException if any of {@code elements} is null
265 public static <E> ImmutableList<E> copyOf(E[] elements) {
266 switch (elements.length) {
270 return new SingletonImmutableList<E>(elements[0]);
272 return construct(elements.clone());
278 Object[] elements = collection.toArray();
279 switch (elements.length) {
284 ImmutableList<E> list = new SingletonImmutableList<E>((E) elements[0]);
289 return construct(elements);
293 /** {@code elements} has to be internally created array. */
294 private static <E> ImmutableList<E> construct(Object... elements) {
295 for (int i = 0; i < elements.length; i++) {
296 checkElementNotNull(elements[i], i);
298 return new RegularImmutableList<E>(elements);
335 * Returns an immutable list of the elements between the specified {@code
511 final Object[] elements;
512 SerializedForm(Object[] elements) {
513 this.elements = elements;
516 return copyOf(elements);
550 * elements of the ones created before it.
576 * Adds each element of {@code elements} to the {@code ImmutableList}.
578 * @param elements the {@code Iterable} to add to the {@code ImmutableList}
580 * @throws NullPointerException if {@code elements} is null or contains a
583 @Override public Builder<E> addAll(Iterable<? extends E> elements) {
584 if (elements instanceof Collection) {
585 Collection<?> collection = (Collection<?>) elements;
588 super.addAll(elements);
593 * Adds each element of {@code elements} to the {@code ImmutableList}.
595 * @param elements the {@code Iterable} to add to the {@code ImmutableList}
597 * @throws NullPointerException if {@code elements} is null or contains a
600 @Override public Builder<E> add(E... elements) {
601 contents.ensureCapacity(contents.size() + elements.length);
602 super.add(elements);
607 * Adds each element of {@code elements} to the {@code ImmutableList}.
609 * @param elements the {@code Iterable} to add to the {@code ImmutableList}
611 * @throws NullPointerException if {@code elements} is null or contains a
614 @Override public Builder<E> addAll(Iterator<? extends E> elements) {
615 super.addAll(elements);