com.sun.tools.javac.util
Class Bits

java.lang.Object
  extended by com.sun.tools.javac.util.Bits

public class Bits
extends java.lang.Object

A class for extensible, mutable bit sets.

This is NOT part of any API supported by Sun Microsystems. If you write code that depends on this, you do so at your own risk. This code and its internal interfaces are subject to change or deletion without notice.


Field Summary
private  int[] bits
           
private static int wordlen
           
private static int wordmask
           
private static int wordshift
           
 
Constructor Summary
Bits()
          Construct an initially empty set.
Bits(int[] bits)
          Construct a set consisting initially of given bit vector.
Bits(int start, int limit)
          Construct a set consisting initially of given range.
 
Method Summary
 Bits andSet(Bits xs)
          this set = this set & xs.
 void clear()
          This set = {}.
 Bits diffSet(Bits xs)
          this set = this set \ xs.
 Bits dup()
          Return a copy of this set.
 void excl(int x)
          Exclude x from this set.
 void incl(int x)
          Include x in this set.
 void inclRange(int start, int limit)
          Include [start..limit) in this set.
 boolean isMember(int x)
          Is x an element of this set?
static void main(java.lang.String[] args)
          Test Bits.nextBit(int).
 int nextBit(int x)
          Return the index of the least bit position >= x that is set.
 Bits orSet(Bits xs)
          this set = this set | xs.
private  void sizeTo(int len)
           
 java.lang.String toString()
          a string representation of this set.
private static int trailingZeroBits(int x)
          Count trailing zero bits in an int.
 Bits xorSet(Bits xs)
          this set = this set ^ xs.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

wordlen

private static final int wordlen
See Also:
Constant Field Values

wordshift

private static final int wordshift
See Also:
Constant Field Values

wordmask

private static final int wordmask
See Also:
Constant Field Values

bits

private int[] bits
Constructor Detail

Bits

public Bits()
Construct an initially empty set.


Bits

public Bits(int[] bits)
Construct a set consisting initially of given bit vector.


Bits

public Bits(int start,
            int limit)
Construct a set consisting initially of given range.

Method Detail

sizeTo

private void sizeTo(int len)

clear

public void clear()
This set = {}.


dup

public Bits dup()
Return a copy of this set.


incl

public void incl(int x)
Include x in this set.


inclRange

public void inclRange(int start,
                      int limit)
Include [start..limit) in this set.


excl

public void excl(int x)
Exclude x from this set.


isMember

public boolean isMember(int x)
Is x an element of this set?


andSet

public Bits andSet(Bits xs)
this set = this set & xs.


orSet

public Bits orSet(Bits xs)
this set = this set | xs.


diffSet

public Bits diffSet(Bits xs)
this set = this set \ xs.


xorSet

public Bits xorSet(Bits xs)
this set = this set ^ xs.


trailingZeroBits

private static int trailingZeroBits(int x)
Count trailing zero bits in an int. Algorithm from "Hacker's Delight" by Henry S. Warren Jr. (figure 5-13)


nextBit

public int nextBit(int x)
Return the index of the least bit position >= x that is set. If none are set, returns -1. This provides a nice way to iterate over the members of a bit set:
  for (int i = bits.nextBit(0); i>=0; i = bits.nextBit(i+1)) ...
  


toString

public java.lang.String toString()
a string representation of this set.

Overrides:
toString in class java.lang.Object

main

public static void main(java.lang.String[] args)
Test Bits.nextBit(int).