PriorityCache { public static long nextPowerOfTwo(int size) { return 1L << (64L - numberOfLeadingZeros((long)max(1, size) - 1L)); } PriorityCache(int size, int rehash);  PriorityCache(int size, int rehash, @NotNull Weigher<K, V> weigher);  PriorityCache(int size, @NotNull Weigher<K, V> weigher);  PriorityCache(int size); static Supplier<PriorityCache<K, V>> factory(final int size, @NotNull final Weigher<K, V> weigher); static Supplier<PriorityCache<K, V>> factory(final int size); static long nextPowerOfTwo(int size); long size(); synchronized boolean put(@NotNull K key, @NotNull V value, int generation, byte initialCost); @SuppressWarnings("unchecked") @Nullable synchronized V get(@NotNull K key, int generation); synchronized void purgeGenerations(@NotNull Predicate<Integer> purge); @Override synchronized String toString(); @NotNull CacheStats getStats(); long estimateCurrentWeight();  }
@Test public void nextPowerOfTwo() { assertEquals(1, PriorityCache.nextPowerOfTwo(-1)); assertEquals(1, PriorityCache.nextPowerOfTwo(-123)); assertEquals(1, PriorityCache.nextPowerOfTwo(0)); assertEquals(1, PriorityCache.nextPowerOfTwo(1)); assertEquals(2, PriorityCache.nextPowerOfTwo(2)); assertEquals(4, PriorityCache.nextPowerOfTwo(3)); assertEquals(4, PriorityCache.nextPowerOfTwo(4)); assertEquals(512, PriorityCache.nextPowerOfTwo(500)); assertEquals(2147483648L, PriorityCache.nextPowerOfTwo(Integer.MAX_VALUE)); }