/** * Create an immutable set of all elements contained in the collection specified * @param col the collection from which elements will be added into the * result set * @param <T> the element type * @return the set contains all elements in the collection * @see #newSet(Collection) */ public static <T> Set<T> Set(Collection<? extends T> col) { return ImmutableSet.of(col); }
/** * Create an immutable set of all elements contained in the collection specified * @param col the collection from which elements will be added into the * result set * @param <T> the element type * @return the set contains all elements in the collection * @see #newSet(Collection) */ public static <T> Set<T> Set(Collection<? extends T> col) { return ImmutableSet.of(col); }
/** * This method is deprecated. Please use {@link #Set(Collection)} instead */ @Deprecated public static <T> Set<T> set(Collection<? extends T> col) { return ImmutableSet.of(col); }
/** * This method is deprecated. Please use {@link #Set(Collection)} instead */ @Deprecated public static <T> Set<T> set(Collection<? extends T> col) { return ImmutableSet.of(col); }
/** * Create an immutable set of an array of elements * @param ta the array from which all elements will be added into * the result set * @param <T> the element type * @return the set contains all elements in the array */ public static <T> Set<T> setOf(T... ta) { java.util.Set<T> set = new HashSet<T>(); Collections.addAll(set, ta); return ImmutableSet.of(set); }
/** * Create an immutable set of a single element * @param element the single element * @param <T> the element type * @return the set that contains only specified element */ public static <T> Set<T> set(T element) { java.util.Set<T> set = new HashSet<T>(); set.add(element); return ImmutableSet.of(set); }
/** * Create an immutable set of an array of elements * @param ta the array from which all elements will be added into * the result set * @param <T> the element type * @return the set contains all elements in the array */ public static <T> Set<T> setOf(T... ta) { java.util.Set<T> set = new HashSet<T>(); Collections.addAll(set, ta); return ImmutableSet.of(set); }
/** * Create an immutable set of a single element * @param element the single element * @param <T> the element type * @return the set that contains only specified element */ public static <T> Set<T> set(T element) { java.util.Set<T> set = new HashSet<T>(); set.add(element); return ImmutableSet.of(set); }
/** * Create an immutable set contains specified elements * @param t1 one element to be added into the result set * @param ta an array from which all elements will be added into the result set * @param <T> the element type * @return a set that contains all elements specified */ public static <T> Set<T> set(T t1, T... ta) { java.util.Set<T> set = new HashSet<T>(); set.add(t1); Collections.addAll(set, ta); return ImmutableSet.of(set); }
/** * Create an immutable set contains specified elements * @param t1 one element to be added into the result set * @param ta an array from which all elements will be added into the result set * @param <T> the element type * @return a set that contains all elements specified */ public static <T> Set<T> set(T t1, T... ta) { java.util.Set<T> set = new HashSet<T>(); set.add(t1); Collections.addAll(set, ta); return ImmutableSet.of(set); }
public C.Set<T> toSet() { checkState(); trimToSize(); Object[] data = buf; buf = null; return (C.Set<T>)ImmutableSet.of(data); }
public C.Set<T> toSet() { checkState(); trimToSize(); Object[] data = buf; buf = null; return (C.Set<T>)ImmutableSet.of(data); }
@Override public C.Set<T> withIn(Collection<? extends T> col) { C.Set<T> others = C.newSet(col); others.retainAll(this); if (isImmutable()) { return ImmutableSet.of(others); } return others; }
@Override public C.Set<T> onlyIn(Collection<? extends T> col) { C.Set<T> others = C.newSet(col); others.removeAll(this); if (isImmutable()) { return ImmutableSet.of(others); } return others; }
@Override public C.Set<T> onlyIn(Collection<? extends T> col) { C.Set<T> others = C.newSet(col); others.removeAll(this); if (isImmutable()) { return ImmutableSet.of(others); } return others; }
@Override public C.Set<T> without(Collection<? super T> col) { C.Set<T> copy = C.newSet(this); copy.removeAll(col); if (isImmutable()) { return ImmutableSet.of(copy); } return copy; }
@Override public C.Set<T> with(Collection<? extends T> col) { C.Set<T> copy = C.newSet(this); copy.addAll(col); if (isImmutable()) { return ImmutableSet.of(copy); } return copy; }
@Override public C.Set<T> without(Collection<? super T> col) { C.Set<T> copy = C.newSet(this); copy.removeAll(col); if (isImmutable()) { return ImmutableSet.of(copy); } return copy; }
@Override public C.Set<T> with(Collection<? extends T> col) { C.Set<T> copy = C.newSet(this); copy.addAll(col); if (isImmutable()) { return ImmutableSet.of(copy); } return copy; }
@Override public C.Set<T> withIn(Collection<? extends T> col) { C.Set<T> others = C.newSet(col); others.retainAll(this); if (isImmutable()) { return ImmutableSet.of(others); } return others; }