Returns the number of consecutive leading one or zero bits.
If network is true, returns the number of consecutive leading one bits.
Otherwise, returns the number of consecutive leading zero bits.

@param network
@return
178949
public int getLeadingBitCount(boolean network) {
		int count = getDivisionCount();
		if(count == 0) {
			return 0;
		}
		long front = network ? getDivision(0).getMaxValue() : 0;
		int prefixLen = 0;
		for(int i = 0; i < count; i++) {
			IPAddressDivision seg = getDivision(i);
			long value = seg.getDivisionValue();
			if(value != front) {
				return prefixLen + seg.getLeadingBitCount(network);
			}
			prefixLen += seg.getBitCount();
		}
		return prefixLen;
	}
1332194
public boolean isValidAddress(NetworkParameters network) {
      byte version = getVersion();
      if (getAllAddressBytes().length != 21) {
         return false;
      }
      return ((byte) (network.getStandardAddressHeader() & 0xFF)) == version
            || ((byte) (network.getMultisigAddressHeader() & 0xFF)) == version;
   }
1369798
public long skip(long n) {
		long skipped=0L;
		int skip;
		while(n>0) {
			if(n<(skip=curr.remaining())) {
				curr.position(curr.position()+(int)n);
				skipped+=skip;
				n=0;
			} else {
				curr.position(curr.limit());
				
				skipped-=skip;
				if(idx<bbs.size()) {
					curr=bbs.get(idx++);
					n-=skip;
				} else {
					n=0;
				}
			}
		}
		return skipped;
	}
1299719
public byte[] getBitString(int len) throws IOException {
        if (len > available())
            throw new IOException("short read of bit string");

        if (len == 0) {
            throw new IOException("Invalid encoding: zero length bit string");
        }

        int numOfPadBits = buf[pos];
        if ((numOfPadBits < 0) || (numOfPadBits > 7)) {
            throw new IOException("Invalid number of padding bits");
        }
        // minus the first byte which indicates the number of padding bits
        byte[] retval = new byte[len - 1];
        System.arraycopy(buf, pos + 1, retval, 0, len - 1);
        if (numOfPadBits != 0) {
            // get rid of the padding bits
            retval[len - 2] &= (0xff << numOfPadBits);
        }
        skip(len);
        return retval;
    }
901196
private static ASN1Primitive getIssuer(byte[] enc) {
        try {
            ASN1InputStream in = new ASN1InputStream(new ByteArrayInputStream(enc));
            ASN1Sequence seq = (ASN1Sequence)in.readObject();
            return (ASN1Primitive)seq.getObjectAt(seq.getObjectAt(0) instanceof DERTaggedObject ? 3 : 2);
        }
        catch (IOException e) {
            throw new ExceptionConverter(e);
        }
    }
945932
public static int count(int[] buffer, int n) {
		final int n1 = n - n % 24;
		final int n2 = n - n % 3;

		int cnt = 0;
		int i;
		for (i = 0; i < n1; i += 24)
			cnt += merging3(buffer, i);
		for (; i < n2; i += 3)
			cnt += merging2(buffer, i);
		cnt += popcount_fbsd2(buffer, i, n);
		return cnt;
	}
934813
public int nextClearBit(final int i) {
    int x = i >> 6; // i / 64 with sign extension
    long w = ~bitmap.get(x);
    w >>>= i;
    if (w != 0) {
      return i + numberOfTrailingZeros(w);
    }
    int length = bitmap.limit();
    for (++x; x < length; ++x) {
      long map = ~bitmap.get(x);
      if (map != 0L) {
        return x * 64 + numberOfTrailingZeros(map);
      }
    }
    return MAX_CAPACITY;
  }
382834
public static String stringFor(int n)
    {
        switch (n)
        {
            case CU_GRAPH_NODE_TYPE_KERNEL: return "CU_GRAPH_NODE_TYPE_KERNEL";
            case CU_GRAPH_NODE_TYPE_MEMCPY: return "CU_GRAPH_NODE_TYPE_MEMCPY";
            case CU_GRAPH_NODE_TYPE_MEMSET: return "CU_GRAPH_NODE_TYPE_MEMSET";
            case CU_GRAPH_NODE_TYPE_HOST: return "CU_GRAPH_NODE_TYPE_HOST";
            case CU_GRAPH_NODE_TYPE_GRAPH: return "CU_GRAPH_NODE_TYPE_GRAPH";
            case CU_GRAPH_NODE_TYPE_EMPTY: return "CU_GRAPH_NODE_TYPE_EMPTY";
        }
        return "INVALID CUgraphNodeType: "+n;
    }
512762
public int first() {
        int val;
        int i;

        for (i = 0; i < data.length; i++) {
            if (data[i] != 0) {
                val = data[i];
                i <<= SHIFT;
                while ((val & 1) == 0) {
                    val >>>= 1;
                    i++;
                }
                return i;
            }
        }
        return -1;
    }
1184946
public static int bitLength (byte[] bytes) {
        Objects.requireNonNull(bytes, Required.BYTES.toString());
        int byteLength = bytes.length;
        
        int length = 0;
        if (byteLength <= MAX_BYTE_LENGTH && byteLength > 0) {
            length = byteLength * BYTES;
        }
        
        return length;
    }
154424
public int read1Bit() throws IOException {
        if (nBit == 8) {
            advance();
            if (curByte == -1) {
                return -1;
            }
        }
        int res = (curByte >> (7 - nBit)) & 1;
        nBit++;

        debugBits.append(res == 0 ? '0' : '1');
        ++bitsRead;

        return res;
    }
1251263
public static int previousClearBit(long v, int start) {
    if(start < 0) {
      return -1;
    }
    start = start < Long.SIZE ? start : Long.SIZE - 1;
    long cur = ~v & (LONG_ALL_BITS >>> -(start + 1));
    return cur == 0 ? -1 : 63 - Long.numberOfLeadingZeros(cur);
  }
1283636
private boolean linkFirst(Node<E> node) {
        // assert lock.isHeldByCurrentThread();
        if (count >= capacity)
            return false;
        Node<E> f = first;
        node.next = f;
        first = node;
        if (last == null)
            last = node;
        else
            f.prev = node;
        ++count;
        notEmpty.signal();
        return true;
    }
950732
def _count_righthand_zero_bits(number, bits):
    
    if number == 0:
        return bits
    return min(bits, _compat_bit_length(~number & (number - 1)))
1268952
public static int previousSetBit(long v, int start) {
    if(start < 0) {
      return -1;
    }
    start = start < Long.SIZE ? start : Long.SIZE - 1;
    long cur = v & (LONG_ALL_BITS >>> -(start + 1));
    return cur == 0 ? -1 : cur == LONG_ALL_BITS ? 0 : 63 - Long.numberOfLeadingZeros(cur);
  }
745425
public static int nextSetBit(long v, int start) {
    if(start >= Long.SIZE) {
      return -1;
    }
    start = start < 0 ? 0 : start;
    long cur = v & (LONG_ALL_BITS << start);
    return cur == 0 ? -1 : cur == LONG_ALL_BITS ? 0 : Long.numberOfTrailingZeros(cur);
  }
440706
public long getIPv4PrefixCount(int prefixLength) {
		checkSubnet(this, prefixLength);
		if(isMultiple()) {
			int networkSegmentIndex = getNetworkSegmentIndex(prefixLength, IPv4Address.BYTES_PER_SEGMENT, IPv4Address.BITS_PER_SEGMENT);
			int hostSegmentIndex = getHostSegmentIndex(prefixLength, IPv4Address.BYTES_PER_SEGMENT, IPv4Address.BITS_PER_SEGMENT);
			boolean hasPrefixedSegment = (networkSegmentIndex == hostSegmentIndex);
			return getCount(i -> {
				if(hasPrefixedSegment && i == networkSegmentIndex) {
					return getSegment(i).getPrefixValueCount();
				}
				return getSegment(i).getValueCount();
			}, networkSegmentIndex + 1);
		}
		return 1;
	}