Search in sources :

Example 1 with ChrDblPair

use of suite.primitive.adt.pair.ChrDblPair in project suite by stupidsing.

the class ChrDblFunUtil method map2.

public static <K1, V1, T> Source2<K1, V1> map2(ChrDbl_Obj<K1> kf0, ChrDbl_Obj<V1> vf0, ChrDblSource source2) {
    ChrDbl_Obj<K1> kf1 = kf0.rethrow();
    ChrDbl_Obj<V1> vf1 = vf0.rethrow();
    ChrDblPair pair1 = ChrDblPair.of((char) 0, (double) 0);
    return pair -> {
        boolean b = source2.source2(pair1);
        if (b)
            pair.update(kf1.apply(pair1.t0, pair1.t1), vf1.apply(pair1.t0, pair1.t1));
        return b;
    };
}
Also used : ChrTest(suite.primitive.ChrPrimitives.ChrTest) Iterator(java.util.Iterator) LogUtil(suite.os.LogUtil) Source2(suite.util.FunUtil2.Source2) ChrDblPair(suite.primitive.adt.pair.ChrDblPair) Source(suite.util.FunUtil.Source) NullableSyncQueue(suite.util.NullableSyncQueue) Thread_(suite.util.Thread_) Fun(suite.util.FunUtil.Fun) Pair(suite.adt.pair.Pair) Sink(suite.util.FunUtil.Sink) Fail(suite.util.Fail) DblTest(suite.primitive.DblPrimitives.DblTest) ChrDblPair(suite.primitive.adt.pair.ChrDblPair)

Example 2 with ChrDblPair

use of suite.primitive.adt.pair.ChrDblPair in project suite by stupidsing.

the class ChrDblFunUtil method isAll.

public static boolean isAll(ChrDblPredicate pred0, ChrDblSource source2) {
    ChrDblPredicate pred1 = pred0.rethrow();
    ChrDblPair pair = ChrDblPair.of((char) 0, (double) 0);
    while (source2.source2(pair)) if (!pred1.test(pair.t0, pair.t1))
        return false;
    return true;
}
Also used : ChrDblPair(suite.primitive.adt.pair.ChrDblPair)

Example 3 with ChrDblPair

use of suite.primitive.adt.pair.ChrDblPair in project suite by stupidsing.

the class ChrDblFunUtil method fold.

public static <K, V, R> R fold(Fun<Pair<R, ChrDblPair>, R> fun0, R init, ChrDblSource source2) {
    Fun<Pair<R, ChrDblPair>, R> fun1 = fun0.rethrow();
    ChrDblPair pair = ChrDblPair.of((char) 0, (double) 0);
    while (source2.source2(pair)) init = fun1.apply(Pair.of(init, pair));
    return init;
}
Also used : ChrDblPair(suite.primitive.adt.pair.ChrDblPair) ChrDblPair(suite.primitive.adt.pair.ChrDblPair) Pair(suite.adt.pair.Pair)

Example 4 with ChrDblPair

use of suite.primitive.adt.pair.ChrDblPair in project suite by stupidsing.

the class ChrDblFunUtil method iterator.

public static <V> Iterator<ChrDblPair> iterator(ChrDblSource source2) {
    return new Iterator<>() {

        private ChrDblPair next = null;

        public boolean hasNext() {
            if (next == null) {
                ChrDblPair next1 = ChrDblPair.of((char) 0, (double) 0);
                if (source2.source2(next1))
                    next = next1;
            }
            return next != null;
        }

        public ChrDblPair next() {
            ChrDblPair next0 = next;
            next = null;
            return next0;
        }
    };
}
Also used : Iterator(java.util.Iterator) ChrDblPair(suite.primitive.adt.pair.ChrDblPair)

Example 5 with ChrDblPair

use of suite.primitive.adt.pair.ChrDblPair in project suite by stupidsing.

the class ChrDblMap method forEach.

public void forEach(ChrDblSink sink) {
    ChrDblPair pair = ChrDblPair.of((char) 0, (double) 0);
    ChrDblSource source = source_();
    while (source.source2(pair)) sink.sink2(pair.t0, pair.t1);
}
Also used : ChrDblPair(suite.primitive.adt.pair.ChrDblPair) ChrDblSource(suite.primitive.ChrDblSource)

Aggregations

ChrDblPair (suite.primitive.adt.pair.ChrDblPair)8 Iterator (java.util.Iterator)3 Pair (suite.adt.pair.Pair)3 LogUtil (suite.os.LogUtil)2 ChrTest (suite.primitive.ChrPrimitives.ChrTest)2 DblTest (suite.primitive.DblPrimitives.DblTest)2 Fail (suite.util.Fail)2 Fun (suite.util.FunUtil.Fun)2 Sink (suite.util.FunUtil.Sink)2 Source (suite.util.FunUtil.Source)2 Source2 (suite.util.FunUtil2.Source2)2 NullableSyncQueue (suite.util.NullableSyncQueue)2 Thread_ (suite.util.Thread_)2 ChrDblSource (suite.primitive.ChrDblSource)1