Search in sources :

Example 1 with Byte2IntOpenHashMap

use of it.unimi.dsi.fastutil.bytes.Byte2IntOpenHashMap in project symja_android_library by axkr.

the class BooleanColumn method summary.

@Override
public Table summary() {
    Byte2IntMap counts = new Byte2IntOpenHashMap(3);
    counts.put(BooleanColumnType.BYTE_FALSE, 0);
    counts.put(BooleanColumnType.BYTE_TRUE, 0);
    for (byte next : data) {
        counts.put(next, counts.get(next) + 1);
    }
    Table table = Table.create(name());
    StringColumn label = StringColumn.create("Value");
    DoubleColumn countColumn = DoubleColumn.create("Count");
    table.addColumns(label);
    table.addColumns(countColumn);
    for (Map.Entry<Byte, Integer> entry : counts.byte2IntEntrySet()) {
        label.append(entry.getKey() == 1 ? "true" : "false");
        countColumn.append(entry.getValue());
    }
    return table;
}
Also used : Byte2IntOpenHashMap(it.unimi.dsi.fastutil.bytes.Byte2IntOpenHashMap) Byte2IntMap(it.unimi.dsi.fastutil.bytes.Byte2IntMap) Map(java.util.Map) Byte2IntOpenHashMap(it.unimi.dsi.fastutil.bytes.Byte2IntOpenHashMap) Byte2IntMap(it.unimi.dsi.fastutil.bytes.Byte2IntMap)

Aggregations

Byte2IntMap (it.unimi.dsi.fastutil.bytes.Byte2IntMap)1 Byte2IntOpenHashMap (it.unimi.dsi.fastutil.bytes.Byte2IntOpenHashMap)1 Map (java.util.Map)1