Search in sources :

Example 1 with IntIntSource

use of suite.primitive.IntIntSource in project suite by stupidsing.

the class IntIntMap1 method streamlet.

public IntObjStreamlet<Integer> streamlet() {
    return new IntObjStreamlet<>(() -> {
        IntIntSource source = source_();
        IntIntPair pair0 = IntIntPair.of(0, 0);
        return IntObjOutlet.of(new IntObjSource<Integer>() {

            public boolean source2(IntObjPair<Integer> pair) {
                boolean b = source.source2(pair0);
                if (b)
                    pair.update(pair0.t0, pair0.t1);
                return b;
            }
        });
    });
}
Also used : IntObjStreamlet(suite.primitive.streamlet.IntObjStreamlet) IntIntSource(suite.primitive.IntIntSource) IntIntPair(suite.primitive.adt.pair.IntIntPair)

Example 2 with IntIntSource

use of suite.primitive.IntIntSource in project suite by stupidsing.

the class IntIntMap1 method forEach.

public void forEach(IntIntSink sink) {
    IntIntPair pair = IntIntPair.of(0, 0);
    IntIntSource source = source_();
    while (source.source2(pair)) sink.sink2(pair.t0, pair.t1);
}
Also used : IntIntSource(suite.primitive.IntIntSource) IntIntPair(suite.primitive.adt.pair.IntIntPair)

Example 3 with IntIntSource

use of suite.primitive.IntIntSource in project suite by stupidsing.

the class IntIntMapTest method test.

@Test
public void test() {
    IntIntMap map = new IntIntMap();
    map.put(1, 2);
    map.put(3, 4);
    map.put(5, 6);
    assertEquals(2, map.get(1));
    assertEquals(4, map.get(3));
    assertEquals(6, map.get(5));
    Set<String> expected = new HashSet<>();
    expected.add("1:2");
    expected.add("3:4");
    expected.add("5:6");
    Set<String> actual = new HashSet<>();
    IntIntSource source = map.source();
    IntIntPair pair = IntIntPair.of(0, 0);
    while (source.source2(pair)) actual.add(pair.t0 + ":" + pair.t1);
    assertEquals(expected, actual);
}
Also used : IntIntMap(suite.primitive.adt.map.IntIntMap) IntIntSource(suite.primitive.IntIntSource) HashSet(java.util.HashSet) IntIntPair(suite.primitive.adt.pair.IntIntPair) Test(org.junit.Test)

Example 4 with IntIntSource

use of suite.primitive.IntIntSource in project suite by stupidsing.

the class IntIntMap method forEach.

public void forEach(IntIntSink sink) {
    IntIntPair pair = IntIntPair.of((int) 0, (int) 0);
    IntIntSource source = source_();
    while (source.source2(pair)) sink.sink2(pair.t0, pair.t1);
}
Also used : IntIntSource(suite.primitive.IntIntSource) IntIntPair(suite.primitive.adt.pair.IntIntPair)

Aggregations

IntIntSource (suite.primitive.IntIntSource)4 IntIntPair (suite.primitive.adt.pair.IntIntPair)4 HashSet (java.util.HashSet)1 Test (org.junit.Test)1 IntIntMap (suite.primitive.adt.map.IntIntMap)1 IntObjStreamlet (suite.primitive.streamlet.IntObjStreamlet)1