@Override public long injectInto(long injectedValue, final LongObjectToLongFunction<? super V> f) { return Iterate.injectInto(injectedValue, this.adapted, new LongObjectToLongFunction<T>() { public long longValueOf(long intParameter, T objectParameter) { return f.longValueOf(intParameter, CollectIterable.this.function.valueOf(objectParameter)); } }); }
@Override public float injectInto(float injectedValue, final FloatObjectToFloatFunction<? super V> f) { return Iterate.injectInto(injectedValue, this.adapted, new FloatObjectToFloatFunction<T>() { public float floatValueOf(float intParameter, T objectParameter) { return f.floatValueOf(intParameter, CollectIterable.this.function.valueOf(objectParameter)); } }); }
@Override public <IV> IV injectInto(IV injectedValue, final Function2<? super IV, ? super V, ? extends IV> f) { return Iterate.injectInto(injectedValue, this.adapted, new Function2<IV, T, IV>() { public IV value(IV argument1, T argument2) { return f.value(argument1, CollectIterable.this.function.valueOf(argument2)); } }); }
@Override public double injectInto(double injectedValue, final DoubleObjectToDoubleFunction<? super V> f) { return Iterate.injectInto(injectedValue, this.adapted, new DoubleObjectToDoubleFunction<T>() { public double doubleValueOf(double intParameter, T objectParameter) { return f.doubleValueOf(intParameter, CollectIterable.this.function.valueOf(objectParameter)); } }); }
@Override public int injectInto(int injectedValue, final IntObjectToIntFunction<? super V> f) { return Iterate.injectInto(injectedValue, this.adapted, new IntObjectToIntFunction<T>() { public int intValueOf(int intParameter, T objectParameter) { return f.intValueOf(intParameter, CollectIterable.this.function.valueOf(objectParameter)); } }); }
private static <T> MutableSet<MutableSet<T>> powerSetWithSeed(Set<T> set, MutableSet<MutableSet<T>> seed) { return Iterate.injectInto(seed, set, new Function2<MutableSet<MutableSet<T>>, T, MutableSet<MutableSet<T>>>() { public MutableSet<MutableSet<T>> value(MutableSet<MutableSet<T>> accumulator, final T element) { return SetIterables.union(accumulator, accumulator.collect(new Function<MutableSet<T>, MutableSet<T>>() { public MutableSet<T> valueOf(MutableSet<T> innerSet) { return innerSet.clone().with(element); } })); } }); }
/** * @see Iterate#injectInto(Object, Iterable, Function2) */ public static <K, V, IV> IV injectInto( IV injectValue, Map<K, V> map, Function2<? super IV, ? super V, ? extends IV> function) { return Iterate.injectInto(injectValue, map.values(), function); }
/** * Same as {@link #injectInto(Object, Map, Function2)}, but only applies the value to the function * if the predicate returns true for the value. * * @see #injectInto(Object, Map, Function2) */ public static <IV, K, V> IV injectIntoIf( IV initialValue, Map<K, V> map, final Predicate<? super V> predicate, final Function2<? super IV, ? super V, ? extends IV> function) { Function2<IV, ? super V, IV> ifFunction = new Function2<IV, V, IV>() { public IV value(IV accumulator, V item) { if (predicate.accept(item)) { return function.value(accumulator, item); } return accumulator; } }; return Iterate.injectInto(initialValue, map.values(), ifFunction); }
public float injectInto(float injectedValue, FloatObjectToFloatFunction<? super T> function) { return Iterate.injectInto(injectedValue, this.getDelegate(), function); }
public int injectInto(int injectedValue, IntObjectToIntFunction<? super T> function) { return Iterate.injectInto(injectedValue, this.getDelegate(), function); }
public double injectInto(double injectedValue, DoubleObjectToDoubleFunction<? super T> function) { return Iterate.injectInto(injectedValue, this.getDelegate(), function); }
public <IV> IV injectInto(IV injectedValue, Function2<? super IV, ? super T, ? extends IV> function) { return Iterate.injectInto(injectedValue, this.getDelegate(), function); }
public long injectInto(long injectedValue, LongObjectToLongFunction<? super T> function) { return Iterate.injectInto(injectedValue, this.getDelegate(), function); }
public static <T> MutableSet<MutableSet<T>> powerSet(Set<T> set) { MutableSet<MutableSet<T>> seed = UnifiedSet.<MutableSet<T>>newSetWith(UnifiedSet.<T>newSet()); return Iterate.injectInto(seed, set, new Function2<MutableSet<MutableSet<T>>, T, MutableSet<MutableSet<T>>>() { public MutableSet<MutableSet<T>> value(MutableSet<MutableSet<T>> accumulator, final T element) { return Sets.union(accumulator, accumulator.collect(new Function<MutableSet<T>, MutableSet<T>>() { public MutableSet<T> valueOf(MutableSet<T> innerSet) { return innerSet.toSet().with(element); } })); } }); }
public static <T> MutableSortedSet<MutableSortedSet<T>> powerSet(SortedSet<T> set) { Comparator<? super T> comparator = set.comparator(); MutableSortedSet<T> innerTree = TreeSortedSet.newSet(comparator); TreeSortedSet<MutableSortedSet<T>> sortedSetIterables = TreeSortedSet.newSet(Comparators.<T>powerSet()); MutableSortedSet<MutableSortedSet<T>> seed = sortedSetIterables.with(innerTree); return Iterate.injectInto(seed, set, new Function2<MutableSortedSet<MutableSortedSet<T>>, T, MutableSortedSet<MutableSortedSet<T>>>() { public MutableSortedSet<MutableSortedSet<T>> value(MutableSortedSet<MutableSortedSet<T>> accumulator, final T element) { return accumulator.union(accumulator.collect(new Function<MutableSortedSet<T>, MutableSortedSet<T>>() { public MutableSortedSet<T> valueOf(MutableSortedSet<T> set) { MutableSortedSet<T> newSet = set.clone(); newSet.add(element); return newSet; } }).toSet()); } }); }
@Override public float injectInto(float injectedValue, final FloatObjectToFloatFunction<? super V> f) { return Iterate.injectInto(injectedValue, this.adapted, new FloatObjectToFloatFunction<T>() { public float floatValueOf(float intParameter, T objectParameter) { return f.floatValueOf(intParameter, CollectIterable.this.function.valueOf(objectParameter)); } }); }
@Override public <IV> IV injectInto(IV injectedValue, final Function2<? super IV, ? super V, ? extends IV> f) { return Iterate.injectInto(injectedValue, this.adapted, new Function2<IV, T, IV>() { public IV value(IV argument1, T argument2) { return f.value(argument1, CollectIterable.this.function.valueOf(argument2)); } }); }
@Override public int injectInto(int injectedValue, final IntObjectToIntFunction<? super V> f) { return Iterate.injectInto(injectedValue, this.adapted, new IntObjectToIntFunction<T>() { public int intValueOf(int intParameter, T objectParameter) { return f.intValueOf(intParameter, CollectIterable.this.function.valueOf(objectParameter)); } }); }
@Override public double injectInto(double injectedValue, final DoubleObjectToDoubleFunction<? super V> f) { return Iterate.injectInto(injectedValue, this.adapted, new DoubleObjectToDoubleFunction<T>() { public double doubleValueOf(double intParameter, T objectParameter) { return f.doubleValueOf(intParameter, CollectIterable.this.function.valueOf(objectParameter)); } }); }
public int injectInto(int injectedValue, IntObjectToIntFunction<? super T> function) { return Iterate.injectInto(injectedValue, this.getDelegate(), function); }