< prev index next >

src/java.base/share/classes/java/util/Set.java

Print this page
rev 47862 : imported patch immu0

*** 446,456 **** * @return an empty {@code Set} * * @since 9 */ static <E> Set<E> of() { ! return ImmutableCollections.Set0.instance(); } /** * Returns an immutable set containing one element. * See <a href="#immutable">Immutable Set Static Factory Methods</a> for details. --- 446,456 ---- * @return an empty {@code Set} * * @since 9 */ static <E> Set<E> of() { ! return ImmutableCollections.emptySet(); } /** * Returns an immutable set containing one element. * See <a href="#immutable">Immutable Set Static Factory Methods</a> for details.
*** 478,488 **** * @throws NullPointerException if an element is {@code null} * * @since 9 */ static <E> Set<E> of(E e1, E e2) { ! return new ImmutableCollections.Set2<>(e1, e2); } /** * Returns an immutable set containing three elements. * See <a href="#immutable">Immutable Set Static Factory Methods</a> for details. --- 478,488 ---- * @throws NullPointerException if an element is {@code null} * * @since 9 */ static <E> Set<E> of(E e1, E e2) { ! return new ImmutableCollections.SetN<>(e1, e2); } /** * Returns an immutable set containing three elements. * See <a href="#immutable">Immutable Set Static Factory Methods</a> for details.
*** 689,703 **** @SafeVarargs @SuppressWarnings("varargs") static <E> Set<E> of(E... elements) { switch (elements.length) { // implicit null check of elements case 0: ! return ImmutableCollections.Set0.instance(); case 1: return new ImmutableCollections.Set1<>(elements[0]); - case 2: - return new ImmutableCollections.Set2<>(elements[0], elements[1]); default: return new ImmutableCollections.SetN<>(elements); } } } --- 689,701 ---- @SafeVarargs @SuppressWarnings("varargs") static <E> Set<E> of(E... elements) { switch (elements.length) { // implicit null check of elements case 0: ! return ImmutableCollections.emptySet(); case 1: return new ImmutableCollections.Set1<>(elements[0]); default: return new ImmutableCollections.SetN<>(elements); } } }
< prev index next >