scala.collection

class BitSet

[source: scala/collection/BitSet.scala]

abstract class BitSet
extends Set[Int]

The class BitSet provides the interface for a space-efficient implementation of dense integer sets represented as bits in array of integers. Bit indices are between 0..(capacity-1) inclusive.

Author
Burak Emir, Stephane Micheloud, Nikolay Mihaylov
Martin Odersky
Version
2.0 01/01/2007
Direct Known Subclasses:
BitSet, BitSet

Method Summary
protected abstract def arr : Array[Int]
abstract def capacity : Int
def contains (i : Int) : Boolean
final def elements : Iterator[Int]
returns an iterator over the truth values of all bits
override def equals (other : Any) : Boolean
Checks if two bitsets are structurally identical. Uses accelerated (32 x faster) check if the other set is a BitSet
override def hashCode : Int
Returns a hash code value for the object.
protected final def mask (n : Int) : Int
protected final def memsize (n : Int) : Int
protected final def nbits (n : Int) : Int
protected final def offset (n : Int) : Int
abstract def size : Int
number of bits in this bitset
protected override def stringPrefix : java.lang.String
Defines the prefix of this object's toString representation.
override def subsetOf (other : Set[Int]) : Boolean
Checks if this set is a subset of set that. Uses accelerated (32 x faster) check if the other set is a BitSet
def underlying : Array[Int]
Methods inherited from Set
apply, isEmpty, *, **, toArray
Methods inherited from Collection
toString
Methods inherited from Iterable
concat, ++, map, flatMap, filter, partition, takeWhile, dropWhile, take, drop, foreach, forall, exists, find, findIndexOf, indexOf, foldLeft, foldRight, /:, :\, reduceLeft, reduceRight, copyToBuffer, sameElements, toList, toSeq, toStream, mkString, mkString, mkString, addString, addString, addString, copyToArray, projection, hasDefiniteSize
Methods inherited from Function1
compose, andThen
Methods inherited from AnyRef
getClass, clone, notify, notifyAll, wait, wait, wait, finalize, ==, !=, eq, ne, synchronized
Methods inherited from Any
==, !=, isInstanceOf, asInstanceOf
Method Details
abstract def size : Int
number of bits in this bitset
Overrides
Set.size

def contains(i : Int) : Boolean
Parameters
i - ...
Returns
true if bit i is set.
Overrides
Set.contains

abstract def capacity : Int

protected abstract def arr : Array[Int]

final def elements : Iterator[Int]
returns an iterator over the truth values of all bits

override def equals(other : Any) : Boolean
Checks if two bitsets are structurally identical. Uses accelerated (32 x faster) check if the other set is a BitSet
Parameters
other - ...
Returns
true, iff both bitsets contain the same elements.
Overrides
Set.equals

override def hashCode : Int
Returns a hash code value for the object.

The default hashing algorithm is platform dependent. Note that it is allowed for two objects to have identical hash codes (o1.hashCode.equals(o2.hashCode)) yet not be equal (o1.equals(o2) returns false). A degenerate implementation could always return 0. However, it is required that if two objects are equal (o1.equals(o2) returns true) that they have identical hash codes (o1.hashCode.equals(o2.hashCode)). Therefore, when overriding this method, be sure to verify that the behavior is consistent with the equals method.

Returns
the hash code value for the object.

Overrides
Set.hashCode

override def subsetOf(other : Set[Int]) : Boolean
Checks if this set is a subset of set that. Uses accelerated (32 x faster) check if the other set is a BitSet
Parameters
other - another set.
Returns
true, iff the other set is a superset of this set.
Overrides
Set.subsetOf

protected final def memsize(n : Int) : Int
Parameters
n - the number of bits to be stored.
Returns
the number of Int cells needed to store n bits.

protected final def nbits(n : Int) : Int
Parameters
n - ...
Returns
the number of bits represented by n words.

protected final def offset(n : Int) : Int
Parameters
n - ...
Returns
the position in the array where the bit resides.

protected final def mask(n : Int) : Int
Parameters
n - ...
Returns
a mask with 1 at the position of the bit.

def underlying : Array[Int]
Returns
a copy of the array underlying this bitset

protected override def stringPrefix : java.lang.String
Defines the prefix of this object's toString representation.
Overrides
Set.stringPrefix