Search in sources :

Example 1 with ChrSource

use of suite.primitive.ChrPrimitives.ChrSource in project suite by stupidsing.

the class ChrSet method forEach.

public void forEach(ChrSink sink) {
    ChrSource source = source_();
    char c;
    while ((c = source.source()) != ChrFunUtil.EMPTYVALUE) sink.sink(c);
}
Also used : ChrSource(suite.primitive.ChrPrimitives.ChrSource)

Example 2 with ChrSource

use of suite.primitive.ChrPrimitives.ChrSource in project suite by stupidsing.

the class ChrOutlet method equals.

@Override
public boolean equals(Object object) {
    if (Object_.clazz(object) == ChrOutlet.class) {
        ChrSource source1 = ((ChrOutlet) object).source;
        char o0, o1;
        while (Objects.equals(o0 = source.source(), o1 = source1.source())) if (o0 == ChrFunUtil.EMPTYVALUE && o1 == ChrFunUtil.EMPTYVALUE)
            return true;
        return false;
    } else
        return false;
}
Also used : ChrSource(suite.primitive.ChrPrimitives.ChrSource)

Example 3 with ChrSource

use of suite.primitive.ChrPrimitives.ChrSource in project suite by stupidsing.

the class ChrFunUtil method suck.

/**
 * Sucks data from a sink and produce into a source.
 */
public static ChrSource suck(Sink<ChrSink> fun) {
    NullableSyncQueue<Character> queue = new NullableSyncQueue<>();
    ChrSink enqueue = c -> enqueue(queue, c);
    Thread thread = Thread_.startThread(() -> {
        try {
            fun.sink(enqueue);
        } finally {
            enqueue(queue, EMPTYVALUE);
        }
    });
    return () -> {
        try {
            return queue.take();
        } catch (InterruptedException ex) {
            thread.interrupt();
            return Fail.t(ex);
        }
    };
}
Also used : ChrTest(suite.primitive.ChrPrimitives.ChrTest) Chr_Obj(suite.primitive.ChrPrimitives.Chr_Obj) ChrSink(suite.primitive.ChrPrimitives.ChrSink) Iterator(java.util.Iterator) LogUtil(suite.os.LogUtil) ChrObjPair(suite.primitive.adt.pair.ChrObjPair) Source2(suite.util.FunUtil2.Source2) Source(suite.util.FunUtil.Source) NullableSyncQueue(suite.util.NullableSyncQueue) Thread_(suite.util.Thread_) Fun(suite.util.FunUtil.Fun) ChrObjSource(suite.primitive.ChrPrimitives.ChrObjSource) Sink(suite.util.FunUtil.Sink) Collections(java.util.Collections) Fail(suite.util.Fail) ChrSource(suite.primitive.ChrPrimitives.ChrSource) NullableSyncQueue(suite.util.NullableSyncQueue) ChrSink(suite.primitive.ChrPrimitives.ChrSink)

Aggregations

ChrSource (suite.primitive.ChrPrimitives.ChrSource)3 Collections (java.util.Collections)1 Iterator (java.util.Iterator)1 LogUtil (suite.os.LogUtil)1 ChrObjSource (suite.primitive.ChrPrimitives.ChrObjSource)1 ChrSink (suite.primitive.ChrPrimitives.ChrSink)1 ChrTest (suite.primitive.ChrPrimitives.ChrTest)1 Chr_Obj (suite.primitive.ChrPrimitives.Chr_Obj)1 ChrObjPair (suite.primitive.adt.pair.ChrObjPair)1 Fail (suite.util.Fail)1 Fun (suite.util.FunUtil.Fun)1 Sink (suite.util.FunUtil.Sink)1 Source (suite.util.FunUtil.Source)1 Source2 (suite.util.FunUtil2.Source2)1 NullableSyncQueue (suite.util.NullableSyncQueue)1 Thread_ (suite.util.Thread_)1