AdaptiveCounting extends LogLog { protected static byte rho(long x, int k) { return (byte) (Long.numberOfLeadingZeros((x << k) | (1 << (k - 1))) + 1); } AdaptiveCounting(int k);  AdaptiveCounting(byte[] M); @Override boolean offer(Object o); @Override long cardinality(); @Override IRichCardinality merge(IRichCardinality... estimators); static AdaptiveCounting mergeEstimators(LogLog... estimators);  }
@Test public void testRho() { assertEquals(17, LogLog.rho(0, 16)); assertEquals(16, LogLog.rho(1, 16)); assertEquals(15, LogLog.rho(2, 16)); assertEquals(1, LogLog.rho(0x00008000, 16)); assertEquals(23, LogLog.rho(0, 10)); assertEquals(22, LogLog.rho(1, 10)); assertEquals(21, LogLog.rho(2, 10)); assertEquals(1, LogLog.rho(0x00200000, 10)); }
@Test public void testRhoL() { assertEquals(49, AdaptiveCounting.rho(0L, 16)); assertEquals(48, AdaptiveCounting.rho(1L, 16)); assertEquals(47, AdaptiveCounting.rho(2L, 16)); assertEquals(1, AdaptiveCounting.rho(0x80008000L, 32)); assertEquals(55, AdaptiveCounting.rho(0L, 10)); assertEquals(54, AdaptiveCounting.rho(1L, 10)); assertEquals(53, AdaptiveCounting.rho(2L, 10)); assertEquals(1, AdaptiveCounting.rho(0x0020000000000000L, 10)); assertEquals(3, AdaptiveCounting.rho(0xDEA07EEFFEEDCAFEL, 15)); }