default boolean equalTo(T other){ return this.equalTo(new Eq<W>() {},other); } default boolean equalTo(Eq<W> eq, T other){
@Override default boolean allMatch(final Predicate<? super Tuple2<K, V>> c) { return Folds.super.allMatch(c); }
default ConvertableSequence<T> to(){ return new ConvertableSequence<>(this); }
/** * Print each value in this Folds to the console in turn (left-to-right) */ default void printOut() { stream().printOut(); }
default <U> Option<T> maxBy(Function<? super T, ? extends U> function, Comparator<? super U> comparator){ return foldLeft(BinaryOperator.maxBy(new Comparator<T>() { @Override public int compare(T o1, T o2) { return comparator.compare(function.apply(o1),function.apply(o2)); } })); } default <U extends Comparable<? super U>> Option<T> maxBy(Function<? super T, ? extends U> function){
default <U extends Comparable<? super U>> Option<T> maxBy(Function<? super T, ? extends U> function){ return maxBy(function, Comparator.naturalOrder()); } default <U extends Comparable<? super U>> Option<T> minBy(Function<? super T, ? extends U> function){
default <U extends Comparable<? super U>> Option<T> minBy(Function<? super T, ? extends U> function){ return minBy(function, Comparator.naturalOrder()); } default <U extends Comparable<? super U>> Option<T> minBy(Function<? super T, ? extends U> function, Comparator<? super U> comparator){
default Seq<T> seq(){ return to().seq(); } default HashSet<T> toHashSet(){
default Option<T> median(){ return atPercentile(50.0); }
default boolean contains(T value){ return anyMatch(p-> Objects.equals(p,value)); } }
/** * <pre> * {@code * assertEquals("123".length(),ReactiveSeq.of(1, 2, 3).join().length()); * } * </pre> * * @return Stream as concatenated String */ default String join() { return stream().join(); }
default <U extends Comparable<? super U>> Option<T> minBy(Function<? super T, ? extends U> function, Comparator<? super U> comparator){ return foldLeft(BinaryOperator.minBy(new Comparator<T>() { @Override public int compare(T o1, T o2) { return comparator.compare(function.apply(o1),function.apply(o2)); } })); } default Option<T> mode(){
public ConvertableSequence<T> to(){ return new ConvertableSequence(this); }
/** * <pre> * {@code * assertEquals("1, 2, 3".length(), ReactiveSeq.of(1, 2, 3).join(", ").length()); * } * </pre> * * @return Stream as concatenated String */ default String join(final String sep) { return stream().join(sep); }
/** * <pre> * {@code * assertEquals("^1|2|3$".length(), of(1, 2, 3).join("|", "^", "$").length()); * } * </pre> * * @return Stream as concatenated String */ default String join(final String sep, final String start, final String end) { return stream().join(sep, start, end); }
/** * Print each value in this Folds to the error console in turn (left-to-right) */ default void printErr() { stream().printErr(); }
/** * Write each element within this Folds in turn to the supplied PrintWriter * * @param writer PrintWriter to tell to */ default void print(final PrintWriter writer) { stream().print(writer); }
/** * * Immutable reduction from right to left * * @param identity Identity value for the combiner function (leaves the input unchanged) * @param accumulator Combining function * @return Reduced value */ default <U> U foldRight(final U identity, final BiFunction<? super T, ? super U, ? extends U> accumulator) { return stream().foldRight(identity, accumulator); }
/** * Write each element within this Folds in turn to the supplied PrintStream * * @param str PrintStream to tell to */ default void print(final PrintStream str) { stream().print(str); }
default Option<T> minimum(Comparator<? super T> comparator){ return stream().sorted(comparator) .elementAt(0l); }