Search in sources :

Example 1 with IntsBuilder

use of suite.primitive.Ints.IntsBuilder in project suite by stupidsing.

the class IntOutlet method toList.

public IntsBuilder toList() {
    IntsBuilder list = new IntsBuilder();
    int c;
    while ((c = next()) != IntFunUtil.EMPTYVALUE) list.append(c);
    return list;
}
Also used : IntsBuilder(suite.primitive.Ints.IntsBuilder)

Example 2 with IntsBuilder

use of suite.primitive.Ints.IntsBuilder in project suite by stupidsing.

the class IntOutlet method toListMap.

public <K> IntObjMap<IntsBuilder> toListMap(Int_Int valueFun) {
    IntObjMap<IntsBuilder> map = new IntObjMap<>();
    int c;
    while ((c = next()) != IntFunUtil.EMPTYVALUE) map.computeIfAbsent(c, k_ -> new IntsBuilder()).append(valueFun.apply(c));
    return map;
}
Also used : IntObjMap(suite.primitive.adt.map.IntObjMap) IntsBuilder(suite.primitive.Ints.IntsBuilder)

Example 3 with IntsBuilder

use of suite.primitive.Ints.IntsBuilder in project suite by stupidsing.

the class DevMain method text.

private Text text(IRopeList<Character> text) {
    IntsBuilder starts = new IntsBuilder();
    IntsBuilder ends = new IntsBuilder();
    IntMutable p0 = IntMutable.of(-1);
    int size = text.size();
    IntSink lf = px -> {
        starts.append(p0.get() + 1);
        ends.append(px);
        p0.update(px);
    };
    for (int p = 0; p < size; p++) {
        char ch = text.get(p);
        if (ch == '\n' || wrapSize < p - p0.get())
            lf.sink(p);
    }
    if (1 < size - p0.get())
        lf.sink(size);
    return new Text(text, starts.toInts().toArray(), ends.toInts().toArray());
}
Also used : LibcJna(suite.ansi.LibcJna) Termios(suite.ansi.Termios) Friends.min(suite.util.Friends.min) Native(com.sun.jna.Native) IntIntPair(suite.primitive.adt.pair.IntIntPair) Predicate(java.util.function.Predicate) IRope(suite.immutable.IRope) Friends.max(suite.util.Friends.max) IntSink(suite.primitive.IntPrimitives.IntSink) Keyboard(suite.ansi.Keyboard) IRopeList(suite.immutable.IRope.IRopeList) FixieFun6(suite.adt.pair.Fixie_.FixieFun6) VK(suite.ansi.Keyboard.VK) FixieFun3(suite.adt.pair.Fixie_.FixieFun3) Sink(suite.util.FunUtil.Sink) FileUtil(suite.os.FileUtil) Chars_(suite.primitive.Chars_) IntsBuilder(suite.primitive.Ints.IntsBuilder) Ints_(suite.primitive.Ints_) IntMutable(suite.primitive.IntMutable) Fail(suite.util.Fail) IntSink(suite.primitive.IntPrimitives.IntSink) IntsBuilder(suite.primitive.Ints.IntsBuilder) IntMutable(suite.primitive.IntMutable)

Aggregations

IntsBuilder (suite.primitive.Ints.IntsBuilder)3 Native (com.sun.jna.Native)1 Predicate (java.util.function.Predicate)1 FixieFun3 (suite.adt.pair.Fixie_.FixieFun3)1 FixieFun6 (suite.adt.pair.Fixie_.FixieFun6)1 Keyboard (suite.ansi.Keyboard)1 VK (suite.ansi.Keyboard.VK)1 LibcJna (suite.ansi.LibcJna)1 Termios (suite.ansi.Termios)1 IRope (suite.immutable.IRope)1 IRopeList (suite.immutable.IRope.IRopeList)1 FileUtil (suite.os.FileUtil)1 Chars_ (suite.primitive.Chars_)1 IntMutable (suite.primitive.IntMutable)1 IntSink (suite.primitive.IntPrimitives.IntSink)1 Ints_ (suite.primitive.Ints_)1 IntObjMap (suite.primitive.adt.map.IntObjMap)1 IntIntPair (suite.primitive.adt.pair.IntIntPair)1 Fail (suite.util.Fail)1 Friends.max (suite.util.Friends.max)1