Here you can find the source of clampPower(int num)
public final static int clampPower(int num)
//package com.java2s; public class Main { public final static int clampPower(int num) { int initialCapacity = 1; // Find the best power of two to hold elements. // Tests "<=" because arrays aren't kept full. if (num >= initialCapacity) { initialCapacity = num;//from w ww. j av a2 s . c om initialCapacity |= (initialCapacity >>> 1); initialCapacity |= (initialCapacity >>> 2); initialCapacity |= (initialCapacity >>> 4); initialCapacity |= (initialCapacity >>> 8); initialCapacity |= (initialCapacity >>> 16); initialCapacity++; if (initialCapacity < 0) // Too many elements, must back off initialCapacity >>>= 1;// Good luck allocating 2 ^ 30 elements } return initialCapacity; } }