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
Constructor and Description
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
Modifier and Type Method and Description
static void andlub(GenKillBits<AnnotationMirror> outarg1, GenKillBits<AnnotationMirror> arg2, QualifierHierarchy annoRelations)
          Merges each gen-kill set in outarg1 with the one corresponding to the same key in arg2 via boolean "and" on each bit.
 void clear(K key, int index)
          Clears the bit (kill) for the key at the specified index.
 boolean contains(K key)
           
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.
static void orlub(GenKillBits<AnnotationMirror> outarg1, GenKillBits<AnnotationMirror> arg2, QualifierHierarchy annoRelations)
          Merges each gen-kill set outarg1 with the one corresponding to the same key in arg2 via boolean "or" on each bit.
 void set(K key, int index)
          Sets the bit (gen) for the key at the specified index.
 String toString()
           
 boolean valid()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, 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

contains

public boolean contains(K key)

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

toString

public String toString()
Overrides:
toString in class Object

andlub

public static void andlub(GenKillBits<AnnotationMirror> outarg1,
                          GenKillBits<AnnotationMirror> arg2,
                          QualifierHierarchy annoRelations)
Merges each gen-kill set in outarg1 with the one corresponding to the same key in arg2 via boolean "and" on each bit. Modifies outarg1's gen-kill set. TODO: lub

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

orlub

public static void orlub(GenKillBits<AnnotationMirror> outarg1,
                         GenKillBits<AnnotationMirror> arg2,
                         QualifierHierarchy annoRelations)
Merges each gen-kill set outarg1 with the one corresponding to the same key in arg2 via boolean "or" on each bit. Modifies outarg1 gen-kill set. TODO: lub.

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

valid

public boolean valid()