public static int findFirst(int[] bits, int idx) {
    int len = bits.length;
    int minBit = idx & 0x1f;

    for (int arrayIdx = idx >> 5; arrayIdx < len; arrayIdx++) {
      int word = bits[arrayIdx];
      if (word != 0) {
        int bitIdx = findFirst(word, minBit);
        if (bitIdx >= 0) {
          return (arrayIdx << 5) + bitIdx;
        }
      }
      minBit = 0;
    }

    return -1;
  }
Finds the lowest-order bit set at or after the given index in the given bit set.

@param bits {@code non-null;} bit set to operate on
@param idx {@code >= 0;} minimum index to return
@return {@code >= -1;} lowest-order bit set at or after {@code idx}, or {@code -1} if there is
    no appropriate bit index to return
android/android_framework/dex-maker/src/main/java/com/android/dx/util/Bits.java