The use of BitSet : BitSet : Collections Data Structure : Java examples (example source code) Organized by topic

Java
C++
PHP


Java  »  Collections Data Structure   » [  BitSet  ]  Screenshots 
 



The use of BitSet



import java.util.BitSet;

public class BitOHoney {
  public static void main(String args[]) {
    String names[] "Java""Source""and",
        "Support"};
    BitSet bits = new BitSet();
    for (int i = 0, n = names.length; i < n; i++) {
      if ((names[i].length() 2== 0) {
        bits.set(i);
      }
    }
    System.out.println(bits);
    System.out.println("Size : " + bits.size());
    System.out.println("Length: " + bits.length());
    for (int i = 0, n = names.length; i < n; i++) {
      if (!bits.get(i)) {
        System.out.println(names[i" is odd");
      }
    }
    BitSet bites = new BitSet();
    bites.set(0);
    bites.set(1);
    bites.set(2);
    bites.set(3);
    bites.andNot(bits);
    System.out.println(bites);
  }
}

           
       
Related examples in the same category
1.  Java 1.5 (5.0) Changes to the API: several of the new bit manipulation methods in Integer. Java 1.5 (5.0) Changes to the API: several of the new bit manipulation methods in Integer.
2.  Manipulating the BitSet Manipulating the BitSet
3.  Another Bitset demo Another Bitset demo
4.  Operations on series of numbers
5.  BitOHoney
6.  BitOps
























Home| Contact Us
Copyright 2003 - 07 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.