checkers.flow
Class GenKillBits<K>

java.lang.Object
  extended by checkers.flow.GenKillBits<K>
Type Parameters:
K - the type of the key

public class GenKillBits<K>
extends Object

Maintains multiple gen-kill sets, "keyed" by a value. For instance, the flow-sensitive inference implemented in Flow uses a GenKillBits keyed by AnnotationMirrors to simultaneously track the gen-kill sets of multiple type qualifiers.

This class is essentially an abstraction for maintaining and combining multiple simultaneous bit vectors.


Constructor Summary
GenKillBits(Collection<K> keys)
          Creates a new GenKillBits with the specified set of keys.
GenKillBits(GenKillBits<K> other)
          Creates a new GenKillBits that is a deep copy of the GenKillBits passed as an argument.
 
Method Summary
 void and(GenKillBits<K> other)
          Merges each gen-kill set in this group with the one corresponding to the same key in other via boolean "and" on each bit.
 void clear(K key, int index)
          Clears the bit (kill) for the key at the specified index.
static
<K> GenKillBits<K>
copy(GenKillBits<K> other)
          Creates a new GenKillBits that is a deep copy of the GenKillBits passed as an argument.
 boolean get(K key, int index)
          Retrieves the bit for the key at the specified index.
 void or(GenKillBits<K> other)
          Merges each gen-kill set in this group with the one corresponding to the same key in other via boolean "or" on each bit.
 void set(K key, int index)
          Sets the bit (gen) for the key at the specified index.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GenKillBits

public GenKillBits(Collection<K> keys)
Creates a new GenKillBits with the specified set of keys. (Once specified, the keys may not be changed.)

Parameters:
keys - the keys for the GenKillBits

GenKillBits

public GenKillBits(GenKillBits<K> other)
Creates a new GenKillBits that is a deep copy of the GenKillBits passed as an argument.

Parameters:
other - the GenKillBits to copy
See Also:
copy(GenKillBits)
Method Detail

copy

public static <K> GenKillBits<K> copy(GenKillBits<K> other)
Creates a new GenKillBits that is a deep copy of the GenKillBits passed as an argument.

Type Parameters:
K - the key type of the group
Parameters:
other - the GenKillBits to copy
Returns:
a deep copy of the contents of g
See Also:
GenKillBits(GenKillBits)

set

public void set(K key,
                int index)
Sets the bit (gen) for the key at the specified index.

Parameters:
key - the key for which the bit should be set
index - the index at which to set the bit
Throws:
IllegalArgumentException - if the key is not one of the keys for this group

get

public boolean get(K key,
                   int index)
Retrieves the bit for the key at the specified index.

Parameters:
key -
index -
Returns:
the value of the bit for the key at the index
Throws:
IllegalArgumentException - if the key is not one of the keys for this group

clear

public void clear(K key,
                  int index)
Clears the bit (kill) for the key at the specified index.

Parameters:
key - the key for which the bit should be set
index - the index at which to set the bit
Throws:
IllegalArgumentException - if the key is not one of the keys for this group

and

public void and(GenKillBits<K> other)
Merges each gen-kill set in this group with the one corresponding to the same key in other via boolean "and" on each bit. Modifies this gen-kill set.

Parameters:
other - the group to "and" with
Throws:
IllegalArgumentException - if the other group is missing a key from this group

or

public void or(GenKillBits<K> other)
Merges each gen-kill set in this group with the one corresponding to the same key in other via boolean "or" on each bit. Modifies this gen-kill set.

Parameters:
other - the group to "or" with
Throws:
IllegalArgumentException - if the other group is missing a key from this group