Code example for BitSet

Methods: cardinality, or

0
	 * Adds to this set all of the elements that are contained in the specified {@code IntSet} if not already present, using an {@code IntSet} 
	 * -optimized process. 
	 */ 
	public boolean addAll(IntSet ints) {
		int oldSize = size();
		bitSet.or(ints.bitSet);
		return oldSize != size();
	} 
 
	public boolean contains(Integer i) {
		return contains(i.intValue());
	} 
 
	public boolean contains(int i) {
		return i >= 0 && bitSet.get(i);
	} 
 
	public boolean isEmpty() { 
		return bitSet.isEmpty();
	} 
 
	public Iterator<Integer> iterator() {
		return new BitSetIterator(); 
	} 
 
	public boolean remove(Integer i) {
		return remove(i.intValue());
	} 
 
	public boolean remove(int i) {
		if (i < 0)
			return false; 
		boolean isPresent = bitSet.get(i);
		if (isPresent)
			bitSet.set(i, false);
		return isPresent;
	} 
 
	/** 
	 * Removes from this set all of the elements that are contained in the specified {@code IntSet} using an {@code IntSet}-optimized process. 
	 */ 
	public boolean removeAll(IntSet ints) {
		int oldSize = size();
		bitSet.andNot(ints.bitSet);
		return oldSize != size();
	} 
 
	/** 
	 * Retains only the elements in this set that are contained in the specified {@code IntSet} using an {@code IntSet}-optimized process. 
	 */ 
	public boolean retainAll(IntSet ints) {
		int oldSize = size();
		bitSet.and(ints.bitSet);
		return oldSize != size();
	} 
 
	public int size() { 
		return bitSet.cardinality();
	} 
 
	/** 
	 * Wraps the provided {@code BitSet} as a {@link Set} returning the result. Any changes to the set will be reflected in {@code b} and vice-versa. 
	 */