/** * @since 9.0. */ public static <T> MutableSet<T> adapt(Set<T> list) { return SetAdapter.adapt(list); }
public static <E> MutableSet<E> adapt(Set<E> set) { if (set instanceof MutableSet) { return (MutableSet<E>) set; } return new SetAdapter<>(set); }
@Override public MutableBooleanSet collectBoolean(BooleanFunction<? super T> booleanFunction) { BooleanHashSet result = new BooleanHashSet(); this.forEach(new CollectBooleanProcedure<>(booleanFunction, result)); return result; }
/** * @deprecated in 6.0. Use {@link OrderedIterable#zipWithIndex()} instead. */ @Deprecated @Override public MutableSet<Pair<T, Integer>> zipWithIndex() { return Iterate.zipWithIndex(this, UnifiedSet.newSet(this.size())); }
@Override public SetAdapter<T> without(T element) { this.remove(element); return this; }
@Override public SetAdapter<T> withAll(Iterable<? extends T> elements) { this.addAllIterable(elements); return this; }
@Override public SetAdapter<T> withoutAll(Iterable<? extends T> elements) { this.removeAllIterable(elements); return this; }
@Override public PartitionMutableSet<T> partition(Predicate<? super T> predicate) { PartitionMutableSet<T> partitionUnifiedSet = new PartitionUnifiedSet<>(); this.forEach(new PartitionProcedure<>(predicate, partitionUnifiedSet)); return partitionUnifiedSet; }
/** * @deprecated in 6.0. Use {@link OrderedIterable#zipWithIndex()} instead. */ @Deprecated @Override public MutableSet<Pair<T, Integer>> zipWithIndex() { return Iterate.zipWithIndex(this, UnifiedSet.newSet(this.size())); }
@Override public SetAdapter<T> without(T element) { this.remove(element); return this; }
@Override public SetAdapter<T> withAll(Iterable<? extends T> elements) { this.addAllIterable(elements); return this; }
@Override public SetAdapter<T> withoutAll(Iterable<? extends T> elements) { this.removeAllIterable(elements); return this; }
/** * @since 9.0. */ public static <T> MutableSet<T> adapt(Set<T> list) { return SetAdapter.adapt(list); }
@Override public <S> MutableSet<S> selectInstancesOf(Class<S> clazz) { MutableSet<S> result = UnifiedSet.newSet(); this.forEach(new SelectInstancesOfProcedure<>(clazz, result)); return result; }
/** * @deprecated in 6.0. Use {@link OrderedIterable#zip(Iterable)} instead. */ @Deprecated @Override public <S> MutableSet<Pair<T, S>> zip(Iterable<S> that) { if (that instanceof Collection || that instanceof RichIterable) { int thatSize = Iterate.sizeOf(that); UnifiedSet<Pair<T, S>> target = UnifiedSet.newSet(Math.min(this.size(), thatSize)); return Iterate.zip(this, that, target); } return Iterate.zip(this, that, UnifiedSet.newSet()); }