Java BitSet countLeadingSimilarBits(BitSet a, BitSet b)

Here you can find the source of countLeadingSimilarBits(BitSet a, BitSet b)

Description

count Leading Similar Bits

License

Apache License

Declaration

private static int countLeadingSimilarBits(BitSet a, BitSet b) 

Method Source Code


//package com.java2s;
//License from project: Apache License 

import java.util.BitSet;

public class Main {
    private static int countLeadingSimilarBits(BitSet a, BitSet b) {
        int result = 0;
        for (int i = 127; i >= 0 && (a.get(i) == b.get(i)); i--) {
            result++;/*from  w w w.  j  a va 2 s .com*/
        }

        return result;
    }
}

Related

  1. combine(int length, BitSet... bitsets)
  2. compare(BitSet a, BitSet b)
  3. copy(BitSet bs)
  4. copyBits(BitSet source, BitSet dest, int fromIndex)
  5. copyBitSetToBitSet(BitSet src, int srcPos, BitSet dest, int destPos, int length)
  6. createBitSetFromBinaryString(String bitsAsBinaryString)
  7. createSimpleBitSet(Set setBits)
  8. decode(BitSet encoded, int encodedBitLength)
  9. decodeIndex(final BitSet bs, final long rangePerDimension)