Lines Matching refs:elements

51   // Casting to any type is safe because the set will never hold any elements.
92 @Deprecated public static <E> ImmutableSet<E> of(E[] elements) {
93 return copyOf(elements);
96 public static <E> ImmutableSet<E> copyOf(E[] elements) {
97 checkNotNull(elements);
98 switch (elements.length) {
102 return of(elements[0]);
104 return create(elements);
108 public static <E> ImmutableSet<E> copyOf(Collection<? extends E> elements) {
109 Iterable<? extends E> iterable = elements;
113 public static <E> ImmutableSet<E> copyOf(Iterable<? extends E> elements) {
114 if (elements instanceof ImmutableSet
115 && !(elements instanceof ImmutableSortedSet)) {
117 ImmutableSet<E> set = (ImmutableSet<E>) elements;
120 return copyOf(elements.iterator());
123 public static <E> ImmutableSet<E> copyOf(Iterator<? extends E> elements) {
124 if (!elements.hasNext()) {
127 E first = elements.next();
128 if (!elements.hasNext()) {
136 delegate.add(checkNotNull(elements.next()));
137 } while (elements.hasNext());
142 // Factory methods that skips the null checks on elements, only used when
143 // the elements are known to be non-null.
155 private static <E> ImmutableSet<E> create(E... elements) {
158 Collections.addAll(set, elements);
196 @Override public Builder<E> add(E... elements) {
197 checkNotNull(elements); // for GWT
198 contents.ensureCapacity(contents.size() + elements.length);
199 super.add(elements);
203 @Override public Builder<E> addAll(Iterable<? extends E> elements) {
204 if (elements instanceof Collection) {
205 Collection<?> collection = (Collection<?>) elements;
208 super.addAll(elements);
212 @Override public Builder<E> addAll(Iterator<? extends E> elements) {
213 super.addAll(elements);