BitSet length - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for BitSet length method.

This code example shows how to use the following methods:get, length, nextClearBit, set
    checkLegalKey(remainder);
 
    if (remainder < 0) {
      return false; 
    } 
    if (bitSet.get((int) remainder)) {
      return false; 
    } 
    bitSet.set((int) remainder);
    int nextClearBit = bitSet.nextClearBit(0);
    if (nextClearBit >= MIN_BITS_TO_SHIFT) {
      bitSet = bitSet.get(nextClearBit,
          Math.max(nextClearBit, bitSet.length()));
      lastBaseKey += nextClearBit;
    } 
    return true; 
  } 
 
  /** 
   * Get the number of set bits 
7
CodeRank
This code example shows how to use the following methods:clear, clone, length
 
    private final BitSet bits;
    protected final int length;
     
    protected BitList(BitSet bits, int length) {
        assert length >= bits.length();
        this.bits = bits;
        this.length = length;
    } 
     
    public static BitList newInstance(BitSet bits, int length) {
        return new BitList(bits, length);
    } 
     
    public int length() { 
        return length;
    } 
 
    public boolean get(int index) {
        if (index<0 || index>=length)

7
CodeRank
This code example shows how to use the following methods:clear, length
        return set.nextSetBit(0);
    } 
 
    public int remove(boolean key) {
        BitSet set = key ? m_true : m_false;
        int idx = set.length()-1;
        set.clear(idx);
        return idx;
    } 
 
    public int remove(boolean key, int value) {
        BitSet set = key ? m_true : m_false;
        if ( set.get(value) ) {
            set.clear(value);
            return value;
        } else { 
            return Integer.MIN_VALUE;
        } 
    } 
 
7
CodeRank
This code example shows how to use the following methods:get, length
     */ 
    public byte[] pack (ISOComponent c) throws ISOException {
    	BitSet bitMapValue = (BitSet) c.getValue();
    	int maxBytesPossible = getLength();
    	int maxBitsAllowedPhysically = maxBytesPossible<<3;
    	int lastBitOn = bitMapValue.length()-1;
        int actualLastBit=lastBitOn; // takes into consideration 2nd and 3rd bit map flags
        if (lastBitOn > 128) {
        	if (bitMapValue.get(65)) {
        		actualLastBit = 192;
            } else { 
                actualLastBit = 128;
            } 
        } else if (lastBitOn > 64) {
            actualLastBit = 128;
        } 
       	if (actualLastBit > maxBitsAllowedPhysically) {
            throw new ISOException ("Bitmap can only hold bits numbered up to " + maxBitsAllowedPhysically + " in the " +
    						getLength() + " bytes available."); 
        } 

6
CodeRank
This code example shows how to use the following methods:and, length, set
 */ 
import java.util.BitSet; 
 
public final class And { 
    public static void main(String[] args) throws Exception {
        BitSet a = new BitSet();
        BitSet b = new BitSet();
 
        a.set(0);
        a.set(70);
        b.set(40);
        a.and(b);
        if (a.length() != 0)
            throw new RuntimeException("Incorrect length after and().");
    } 
} 
7
CodeRank
This code example shows how to use the following methods:and, length, set
 */ 
import java.util.BitSet; 
 
public final class And { 
    public static void main(String[] args) throws Exception {
        BitSet a = new BitSet();
        BitSet b = new BitSet();
 
        a.set(0);
        a.set(70);
        b.set(40);
        a.and(b);
        if (a.length() != 0)
            throw new RuntimeException("Incorrect length after and().");
    } 
} 
7
CodeRank
This code example shows how to use the following methods:and, length, set
 */ 
import java.util.BitSet;
 
public final class And { 
    public static void main(String[] args) throws Exception {
        BitSet a = new BitSet();
        BitSet b = new BitSet();
 
        a.set(0);
        a.set(70);
        b.set(40);
        a.and(b);
        if (a.length() != 0)
            throw new RuntimeException("Incorrect length after and().");
    } 
} 
6
CodeRank
This code example shows how to use the following methods:and, length, set
 */ 
import java.util.BitSet; 
 
public final class And { 
    public static void main(String[] args) throws Exception {
        BitSet a = new BitSet();
        BitSet b = new BitSet();
 
        a.set(0);
        a.set(70);
        b.set(40);
        a.and(b);
        if (a.length() != 0)
            throw new RuntimeException("Incorrect length after and().");
    } 
} 
7
CodeRank
This code example shows how to use the following methods:clear, length
        return set.nextSetBit(0);
    } 
 
    public int remove(boolean key) {
        BitSet set = key ? m_true : m_false;
        int idx = set.length()-1;
        set.clear(idx);
        return idx;
    } 
 
    public int remove(boolean key, int value) {
        BitSet set = key ? m_true : m_false;
        if ( set.get(value) ) {
            set.clear(value);
            return value;
        } else { 
            return Integer.MIN_VALUE;
        } 
    } 
 
6
CodeRank
This code example shows how to use the following methods:length
     */ 
    public byte[] pack (ISOComponent c) throws ISOException {
        BitSet b = (BitSet) c.getValue();
        int len = 
            getLength() >= 8 ? 
                (((b.length()+62)>>6)<<3) : getLength();
        return ISOUtil.bitSet2byte (b, len);
    } 
    /** 
     * @param c - the Component to unpack 
     * @param b - binary image 
     * @param offset - starting offset within the binary image 
     * @return consumed bytes 
     * @exception ISOException 
     */ 
    public int unpack (ISOComponent c, byte[] b, int offset)
        throws ISOException 
    { 
        int len;
        BitSet bmap = ISOUtil.byte2BitSet (b, offset, getLength() << 3);
5
CodeRank
length Method Overview
Returns the "logical size" of this BitSet: the index of the highest set bit in the BitSet plus one.
See Code Examples for other Java 8 BitSet Methods: