Lines Matching defs:elements

37  * iteration order. Does not permit null elements.
75 // Casting to any type is safe because the set will never hold any elements.
92 * Returns an immutable set containing the given elements, in order. Repeated
103 * Returns an immutable set containing the given elements, in order. Repeated
114 * Returns an immutable set containing the given elements, in order. Repeated
125 * Returns an immutable set containing the given elements, in order. Repeated
136 * Returns an immutable set containing the given elements, in order. Repeated
146 Object[] elements = new Object[paramCount + others.length];
147 elements[0] = e1;
148 elements[1] = e2;
149 elements[2] = e3;
150 elements[3] = e4;
151 elements[4] = e5;
152 elements[5] = e6;
153 for (int i = paramCount; i < elements.length; i++) {
154 elements[i] = others[i - paramCount];
156 return construct(elements);
159 /** {@code elements} has to be internally created array. */
160 private static <E> ImmutableSet<E> construct(Object... elements) {
161 int tableSize = chooseTableSize(elements.length);
166 for (int i = 0; i < elements.length; i++) {
167 Object element = elements[i];
183 uniqueElementsList = new ArrayList<Object>(elements.length);
185 Object previous = elements[k];
194 ? elements
197 // There is only one element or elements are all duplicates
213 // If the set has this many elements, it will "max out" the table size
219 * smallest power of two that can hold setSize elements while being at most
233 * Returns an immutable set containing the given elements, in order. Repeated
237 * @throws NullPointerException if any of {@code elements} is null
240 public static <E> ImmutableSet<E> copyOf(E[] elements) {
242 // copyFromCollection(Arrays.asList(elements))?
243 switch (elements.length) {
247 return of(elements[0]);
249 return construct(elements.clone());
254 * Returns an immutable set containing the given elements, in order. Repeated
256 * first are ignored. This method iterates over {@code elements} at most once.
268 * @throws NullPointerException if any of {@code elements} is null
270 public static <E> ImmutableSet<E> copyOf(Iterable<? extends E> elements) {
271 return (elements instanceof Collection)
272 ? copyOf(Collections2.cast(elements))
273 : copyOf(elements.iterator());
277 * Returns an immutable set containing the given elements, in order. Repeated
281 * @throws NullPointerException if any of {@code elements} is null
283 public static <E> ImmutableSet<E> copyOf(Iterator<? extends E> elements) {
286 return copyFromCollection(Lists.newArrayList(elements));
290 * Returns an immutable set containing the given elements, in order. Repeated
292 * first are ignored. This method iterates over {@code elements} at most
313 * <p>This method is safe to use even when {@code elements} is a synchronized
317 * @throws NullPointerException if any of {@code elements} is null
320 public static <E> ImmutableSet<E> copyOf(Collection<? extends E> elements) {
321 if (elements instanceof ImmutableSet
322 && !(elements instanceof ImmutableSortedSet)) {
324 ImmutableSet<E> set = (ImmutableSet<E>) elements;
329 return copyFromCollection(elements);
334 Object[] elements = collection.toArray();
335 switch (elements.length) {
340 E onlyElement = (E) elements[0];
345 return construct(elements);
378 // the elements (two or more) in the desired order.
379 final transient Object[] elements;
381 ArrayImmutableSet(Object[] elements) {
382 this.elements = elements;
387 return elements.length;
396 * create() method above, which only permits elements of type E.
400 return (UnmodifiableIterator<E>) Iterators.forArray(elements);
405 System.arraycopy(elements, 0, array, 0, size());
416 System.arraycopy(elements, 0, array, 0, size);
430 for (Object target : ((ArrayImmutableSet<?>) targets).elements) {
443 return new ImmutableAsList<E>(elements, this);
513 final Object[] elements;
514 SerializedForm(Object[] elements) {
515 this.elements = elements;
518 return copyOf(elements);
576 * Adds each element of {@code elements} to the {@code ImmutableSet},
577 * ignoring duplicate elements (only the first duplicate element is added).
579 * @param elements the elements to add
581 * @throws NullPointerException if {@code elements} is null or contains a
584 @Override public Builder<E> add(E... elements) {
585 contents.ensureCapacity(contents.size() + elements.length);
586 super.add(elements);
591 * Adds each element of {@code elements} to the {@code ImmutableSet},
592 * ignoring duplicate elements (only the first duplicate element is added).
594 * @param elements the {@code Iterable} to add to the {@code ImmutableSet}
596 * @throws NullPointerException if {@code elements} is null or contains a
599 @Override public Builder<E> addAll(Iterable<? extends E> elements) {
600 if (elements instanceof Collection) {
601 Collection<?> collection = (Collection<?>) elements;
604 super.addAll(elements);
609 * Adds each element of {@code elements} to the {@code ImmutableSet},
610 * ignoring duplicate elements (only the first duplicate element is added).
612 * @param elements the elements to add to the {@code ImmutableSet}
614 * @throws NullPointerException if {@code elements} is null or contains a
617 @Override public Builder<E> addAll(Iterator<? extends E> elements) {
618 super.addAll(elements);