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);
}
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;
}
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);
}
};
}
Aggregations