@Test public void test_2() throws Exception{ LongsRank0OnlySuccinctBitVector bv = new LongsRank0OnlySuccinctBitVector( new byte[]{127, -12, -102, -1, -6, 95, -1, -33, -128}, 65 ); Assert.assertEquals(52, bv.rank1(64)); }
public int rank1(int pos){ int cn = pos / BITS_IN_COUNTCACHE; if((pos + 1) % BITS_IN_COUNTCACHE == 0) return countCache1[cn]; int ret = (cn > 0) ? countCache1[cn - 1] : 0; int n = pos / BITS_IN_BLOCK; for(int i = (cn * BITS_IN_COUNTCACHE / BITS_IN_BLOCK); i < n; i++){ ret += Long.bitCount(longs[i]); } return ret + Long.bitCount(longs[n] & (0x8000000000000000L >> (pos % BITS_IN_BLOCK))); }
LongsRank1OnlySuccinctBitVector implements Serializable, SuccinctBitVector { public int rank1(int pos){ int cn = pos / BITS_IN_COUNTCACHE; if((pos + 1) % BITS_IN_COUNTCACHE == 0) return countCache1[cn]; int ret = (cn > 0) ? countCache1[cn - 1] : 0; int n = pos / BITS_IN_BLOCK; for(int i = (cn * BITS_IN_COUNTCACHE / BITS_IN_BLOCK); i < n; i++){ ret += Long.bitCount(longs[i]); } return ret + Long.bitCount(longs[n] & (0x8000000000000000L >> (pos % BITS_IN_BLOCK))); } }
LongsRank1OnlySuccinctBitVector implements Serializable, SuccinctBitVector { public int rank1(int pos){ int cn = pos / BITS_IN_COUNTCACHE; if((pos + 1) % BITS_IN_COUNTCACHE == 0) return countCache1[cn]; int ret = (cn > 0) ? countCache1[cn - 1] : 0; int n = pos / BITS_IN_BLOCK; for(int i = (cn * BITS_IN_COUNTCACHE / BITS_IN_BLOCK); i < n; i++){ ret += Long.bitCount(longs[i]); } return ret + Long.bitCount(longs[n] & (0x8000000000000000L >> (pos % BITS_IN_BLOCK))); } LongsRank1OnlySuccinctBitVector();  LongsRank1OnlySuccinctBitVector(int initialCapacity);  LongsRank1OnlySuccinctBitVector(byte[] bytes, int bitsSize);  LongsRank1OnlySuccinctBitVector(
			long[] longs, int size, int size1,
			int[] countCache1); }
LongsRank1OnlySuccinctBitVector implements Serializable, SuccinctBitVector { public int rank1(int pos){ int cn = pos / BITS_IN_COUNTCACHE; if((pos + 1) % BITS_IN_COUNTCACHE == 0) return countCache1[cn]; int ret = (cn > 0) ? countCache1[cn - 1] : 0; int n = pos / BITS_IN_BLOCK; for(int i = (cn * BITS_IN_COUNTCACHE / BITS_IN_BLOCK); i < n; i++){ ret += Long.bitCount(longs[i]); } return ret + Long.bitCount(longs[n] & (0x8000000000000000L >> (pos % BITS_IN_BLOCK))); } LongsRank1OnlySuccinctBitVector();  LongsRank1OnlySuccinctBitVector(int initialCapacity);  LongsRank1OnlySuccinctBitVector(byte[] bytes, int bitsSize);  LongsRank1OnlySuccinctBitVector(
			long[] longs, int size, int size1,
			int[] countCache1); @Override String toString(); long[] getLongs(); int[] getCountCache1(); @Override boolean get(int pos); boolean isZero(int pos); boolean isOne(int pos); int size(); int getSize1(); void trimToSize(); void append1(); void append0(); void append(boolean bit); int rank0(int pos); int rank1(int pos); int rank(int pos, boolean b); @Override int select0(int count); @Override int select1(int count); int select(int count, boolean b); int next0(int pos); }
LongsRank1OnlySuccinctBitVector implements Serializable, SuccinctBitVector { public int rank1(int pos){ int cn = pos / BITS_IN_COUNTCACHE; if((pos + 1) % BITS_IN_COUNTCACHE == 0) return countCache1[cn]; int ret = (cn > 0) ? countCache1[cn - 1] : 0; int n = pos / BITS_IN_BLOCK; for(int i = (cn * BITS_IN_COUNTCACHE / BITS_IN_BLOCK); i < n; i++){ ret += Long.bitCount(longs[i]); } return ret + Long.bitCount(longs[n] & (0x8000000000000000L >> (pos % BITS_IN_BLOCK))); } LongsRank1OnlySuccinctBitVector();  LongsRank1OnlySuccinctBitVector(int initialCapacity);  LongsRank1OnlySuccinctBitVector(byte[] bytes, int bitsSize);  LongsRank1OnlySuccinctBitVector(
			long[] longs, int size, int size1,
			int[] countCache1); @Override String toString(); long[] getLongs(); int[] getCountCache1(); @Override boolean get(int pos); boolean isZero(int pos); boolean isOne(int pos); int size(); int getSize1(); void trimToSize(); void append1(); void append0(); void append(boolean bit); int rank0(int pos); int rank1(int pos); int rank(int pos, boolean b); @Override int select0(int count); @Override int select1(int count); int select(int count, boolean b); int next0(int pos);  }