Lines Matching defs:elements

39  * iteration order. Does not permit null elements.
81 // Casting to any type is safe because the set will never hold any elements.
98 * Returns an immutable set containing the given elements, in order. Repeated
109 * Returns an immutable set containing the given elements, in order. Repeated
120 * Returns an immutable set containing the given elements, in order. Repeated
131 * Returns an immutable set containing the given elements, in order. Repeated
142 * Returns an immutable set containing the given elements, in order. Repeated
152 Object[] elements = new Object[paramCount + others.length];
153 elements[0] = e1;
154 elements[1] = e2;
155 elements[2] = e3;
156 elements[3] = e4;
157 elements[4] = e5;
158 elements[5] = e6;
159 System.arraycopy(others, 0, elements, paramCount, others.length);
160 return construct(elements.length, elements);
164 * Constructs an {@code ImmutableSet} from the first {@code n} elements of the specified array.
165 * If {@code k} is the size of the returned {@code ImmutableSet}, then the unique elements of
166 * {@code elements} will be in the first {@code k} positions, and {@code elements[i] == null} for
169 * <p>This may modify {@code elements}. Additionally, if {@code n == elements.length} and
170 * {@code elements} contains no duplicates, {@code elements} may be used without copying in the
173 * <p>{@code elements} may contain only values of type {@code E}.
175 * @throws NullPointerException if any of the first {@code n} elements of {@code elements} is
178 private static <E> ImmutableSet<E> construct(int n, Object... elements) {
183 @SuppressWarnings("unchecked") // safe; elements contains only E's
184 E elem = (E) elements[0];
195 Object element = checkElementNotNull(elements[i], i);
202 elements[uniques++] = element;
211 Arrays.fill(elements, uniques, n, null);
213 // There is only one element or elements are all duplicates
215 E element = (E) elements[0];
220 return construct(uniques, elements);
222 Object[] uniqueElements = (uniques < elements.length)
223 ? ObjectArrays.arraysCopyOf(elements, uniques)
224 : elements;
235 // If the set has this many elements, it will "max out" the table size
242 * returned size is the smallest power of two that can hold setSize elements
264 * Returns an immutable set containing the given elements, in order. Repeated
268 * @throws NullPointerException if any of {@code elements} is null
271 public static <E> ImmutableSet<E> copyOf(E[] elements) {
272 switch (elements.length) {
276 return of(elements[0]);
278 return construct(elements.length, elements.clone());
283 * Returns an immutable set containing the given elements, in order. Repeated
285 * first are ignored. This method iterates over {@code elements} at most once.
297 * @throws NullPointerException if any of {@code elements} is null
299 public static <E> ImmutableSet<E> copyOf(Iterable<? extends E> elements) {
300 return (elements instanceof Collection)
301 ? copyOf((Collection<? extends E>) elements)
302 : copyOf(elements.iterator());
306 * Returns an immutable set containing the given elements, in order. Repeated
310 * @throws NullPointerException if any of {@code elements} is null
312 public static <E> ImmutableSet<E> copyOf(Iterator<? extends E> elements) {
313 // We special-case for 0 or 1 elements, but anything further is madness.
314 if (!elements.hasNext()) {
317 E first = elements.next();
318 if (!elements.hasNext()) {
323 .addAll(elements)
329 * Returns an immutable set containing the given elements, in order. Repeated
331 * first are ignored. This method iterates over {@code elements} at most
352 * <p>This method is safe to use even when {@code elements} is a synchronized
356 * @throws NullPointerException if any of {@code elements} is null
359 public static <E> ImmutableSet<E> copyOf(Collection<? extends E> elements) {
364 if (elements instanceof ImmutableSet
365 && !(elements instanceof ImmutableSortedSet)) {
367 ImmutableSet<E> set = (ImmutableSet<E>) elements;
371 } else if (elements instanceof EnumSet) {
372 return copyOfEnumSet((EnumSet) elements);
374 Object[] array = elements.toArray();
418 final Object[] elements;
419 SerializedForm(Object[] elements) {
420 this.elements = elements;
423 return copyOf(elements);
485 * Adds each element of {@code elements} to the {@code ImmutableSet},
486 * ignoring duplicate elements (only the first duplicate element is added).
488 * @param elements the elements to add
490 * @throws NullPointerException if {@code elements} is null or contains a
493 @Override public Builder<E> add(E... elements) {
494 super.add(elements);
499 * Adds each element of {@code elements} to the {@code ImmutableSet},
500 * ignoring duplicate elements (only the first duplicate element is added).
502 * @param elements the {@code Iterable} to add to the {@code ImmutableSet}
504 * @throws NullPointerException if {@code elements} is null or contains a
507 @Override public Builder<E> addAll(Iterable<? extends E> elements) {
508 super.addAll(elements);
513 * Adds each element of {@code elements} to the {@code ImmutableSet},
514 * ignoring duplicate elements (only the first duplicate element is added).
516 * @param elements the elements to add to the {@code ImmutableSet}
518 * @throws NullPointerException if {@code elements} is null or contains a
521 @Override public Builder<E> addAll(Iterator<? extends E> elements) {
522 super.addAll(elements);