public int getMask(int length) { int res = 0; for (int i = 0 ; i < length ; i++) { res = (res << 1) + 1; } return res; }