cc.mallet.grmm.types
Class BitVarSet

java.lang.Object
  extended by java.util.AbstractCollection<E>
      extended by java.util.AbstractSet
          extended by cc.mallet.grmm.types.BitVarSet
All Implemented Interfaces:
VarSet, java.lang.Cloneable, java.lang.Iterable, java.util.Collection, java.util.Set

public class BitVarSet
extends java.util.AbstractSet
implements VarSet

A clique that uses very little time and memory based on the flyweight pattern. The owner supplies an Alphabet of vertices and a BitSet, and the clique contains the vertices in the Alphabet, masked by the BitSet.

Version:
$Id: BitVarSet.java,v 1.1 2007/10/22 21:37:44 mccallum Exp $
Author:
Charles Sutton

Constructor Summary
BitVarSet(Universe universe, java.util.BitSet included)
          Creates a BitSet clique given an alphabet of Variables, and a bitset that says which variables in the alphabet to include in the clique.
BitVarSet(Universe universe, java.util.Collection included)
           
BitVarSet(VarSet vsOld)
           
 
Method Summary
 boolean add(java.lang.Object o)
           
 AssignmentIterator assignmentIterator()
          Returns an iterator over the assignments to this clique.
 void clear()
           
 boolean contains(java.lang.Object o)
           
 boolean containsAll(BitVarSet bsc)
          Efficient version of containsAll() for BitSetCliques.
 boolean containsAll(java.util.Collection c)
           
 Variable get(int idx)
          Returns the variable in this clique at index idx.
 java.lang.String getLabel()
           
 int hashCode()
           
 boolean hasLabel()
           
 VarSet intersection(VarSet c)
          Returns the intersection of two cliques.
 int intersectionSize(BitVarSet bsc)
          Returns the number of variables in the intersection between this clique and other.
 boolean isEmpty()
           
 java.util.Iterator iterator()
           
 void setLabel(java.lang.String s)
           
 int size()
           
 java.lang.String toString()
           
 Variable[] toVariableArray()
          Returns the variables in this clique as an array, that should not be modified.
 int weight()
          Returns the number of assignments of this clique.
 
Methods inherited from class java.util.AbstractSet
equals, removeAll
 
Methods inherited from class java.util.AbstractCollection
addAll, remove, retainAll, toArray, toArray
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.Set
addAll, equals, remove, removeAll, retainAll, toArray, toArray
 

Constructor Detail

BitVarSet

public BitVarSet(Universe universe,
                 java.util.BitSet included)
Creates a BitSet clique given an alphabet of Variables, and a bitset that says which variables in the alphabet to include in the clique. Neither is copied, but neither is modified, either.

Parameters:
universe -
included - Bit mask that indicates which variables to include

BitVarSet

public BitVarSet(Universe universe,
                 java.util.Collection included)

BitVarSet

public BitVarSet(VarSet vsOld)
Method Detail

add

public boolean add(java.lang.Object o)
Specified by:
add in interface java.util.Collection
Specified by:
add in interface java.util.Set
Overrides:
add in class java.util.AbstractCollection

get

public Variable get(int idx)
Description copied from interface: VarSet
Returns the variable in this clique at index idx.

Specified by:
get in interface VarSet
Returns:
the variable

toVariableArray

public Variable[] toVariableArray()
Description copied from interface: VarSet
Returns the variables in this clique as an array, that should not be modified.

Specified by:
toVariableArray in interface VarSet
Returns:
An array of Variables.

weight

public int weight()
Description copied from interface: VarSet
Returns the number of assignments of this clique.

Specified by:
weight in interface VarSet

assignmentIterator

public AssignmentIterator assignmentIterator()
Description copied from interface: VarSet
Returns an iterator over the assignments to this clique. Each element in the Iterator is an Assignment object.

Specified by:
assignmentIterator in interface VarSet
Returns:
An iterator over assignments

size

public int size()
Specified by:
size in interface java.util.Collection
Specified by:
size in interface java.util.Set
Specified by:
size in class java.util.AbstractCollection

isEmpty

public boolean isEmpty()
Specified by:
isEmpty in interface java.util.Collection
Specified by:
isEmpty in interface java.util.Set
Overrides:
isEmpty in class java.util.AbstractCollection

contains

public boolean contains(java.lang.Object o)
Specified by:
contains in interface java.util.Collection
Specified by:
contains in interface java.util.Set
Overrides:
contains in class java.util.AbstractCollection

iterator

public java.util.Iterator iterator()
Specified by:
iterator in interface java.lang.Iterable
Specified by:
iterator in interface java.util.Collection
Specified by:
iterator in interface java.util.Set
Specified by:
iterator in class java.util.AbstractCollection

hashCode

public int hashCode()
Specified by:
hashCode in interface java.util.Collection
Specified by:
hashCode in interface java.util.Set
Overrides:
hashCode in class java.util.AbstractSet

containsAll

public boolean containsAll(java.util.Collection c)
Specified by:
containsAll in interface java.util.Collection
Specified by:
containsAll in interface java.util.Set
Overrides:
containsAll in class java.util.AbstractCollection

containsAll

public boolean containsAll(BitVarSet bsc)
Efficient version of containsAll() for BitSetCliques.


intersection

public VarSet intersection(VarSet c)
Description copied from interface: VarSet
Returns the intersection of two cliques.

Specified by:
intersection in interface VarSet

intersectionSize

public int intersectionSize(BitVarSet bsc)
Returns the number of variables in the intersection between this clique and other. Equivalent to intersection(bsc).size(), but more efficient.

Parameters:
bsc - Other clique to intersect with

clear

public void clear()
Specified by:
clear in interface java.util.Collection
Specified by:
clear in interface java.util.Set
Overrides:
clear in class java.util.AbstractCollection

hasLabel

public boolean hasLabel()

getLabel

public java.lang.String getLabel()

toString

public java.lang.String toString()
Overrides:
toString in class java.util.AbstractCollection

setLabel

public void setLabel(java.lang.String s)