Java Code Examples for it.unimi.dsi.io.InputBitStream#readUnary()

The following examples show how to use it.unimi.dsi.io.InputBitStream#readUnary() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: EliasFanoBitStreamCODEC.java    From RankSys with Mozilla Public License 2.0 5 votes vote down vote up
@Override
protected void read(InputBitStream ibs, int[] out, int offset, int len) throws IOException {
    int d = 0;
    final int l = ibs.readInt(32);
    for (int i = offset; i < offset + len; i++) {
        final int hx = (d += ibs.readUnary());
        out[i] = hx << l | ibs.readInt(l);
    }
}
 
Example 2
Source File: RiceBitStreamCODEC.java    From RankSys with Mozilla Public License 2.0 5 votes vote down vote up
@Override
protected void read(InputBitStream ibs, int[] out, int offset, int len) throws IOException {
    final int log2b = ibs.readInt(32);
    for (int i = offset; i < offset + len; i++) {
        final int q = ibs.readUnary();
        out[i] = log2b == 0 ? q : (q << log2b) | ibs.readInt(log2b);
    }
}