cc.mallet.grmm.types
Class HashVarSet

java.lang.Object
  extended by cc.mallet.grmm.types.HashVarSet
All Implemented Interfaces:
VarSet, java.io.Serializable, java.lang.Cloneable, java.lang.Iterable, java.util.Collection, java.util.Set
Direct Known Subclasses:
ACRF.UnrolledVarSet

public class HashVarSet
extends java.lang.Object
implements VarSet, java.io.Serializable

A clique is a collection of nodes in a graph that are all adjacent. We implement it cheaply by delegating to a HashSet. Created: Wed Sep 17 12:50:01 2003

Version:
$Id: HashVarSet.java,v 1.1 2007/10/22 21:37:44 mccallum Exp $
Author:
Charles Sutton
See Also:
Serialized Form

Constructor Summary
HashVarSet()
          Create an empty clique.
HashVarSet(java.util.Collection c)
          Create a Clique given a Collection of nodes.
HashVarSet(Variable[] vars)
           
 
Method Summary
 boolean add(java.lang.Object object)
           
 boolean add(java.lang.Object object, boolean checkSorted)
           
 boolean addAll(java.util.Collection collection)
           
 AssignmentIterator assignmentIterator()
          Returns an iterator over the assignments to this clique.
 void clear()
           
 java.lang.Object clone()
           
 boolean contains(java.lang.Object object)
           
 boolean containsAll(java.util.Collection collection)
           
 boolean equals(java.lang.Object object)
           
 Variable get(int idx)
          Returns the variable in this clique at index idx.
 java.lang.String getLabel()
           
 int hashCode()
           
 VarSet intersection(VarSet c)
          Returns the intersection of two cliques.
 boolean isEmpty()
           
 java.util.Iterator iterator()
           
 boolean remove(java.lang.Object object)
           
 boolean removeAll(java.util.Collection collection)
           
 boolean retainAll(java.util.Collection collection)
           
 int size()
           
 java.lang.Object[] toArray()
          Returns the variables in this clique as an array.
 java.lang.Object[] toArray(java.lang.Object[] objectArray)
          Returns the variables in this clique as an array.
 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.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

HashVarSet

public HashVarSet()
Create an empty clique.


HashVarSet

public HashVarSet(java.util.Collection c)
Create a Clique given a Collection of nodes.


HashVarSet

public HashVarSet(Variable[] vars)
Method Detail

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

getLabel

public java.lang.String getLabel()

intersection

public VarSet intersection(VarSet c)
Returns the intersection of two cliques.

Specified by:
intersection in interface VarSet

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.lang.Object

equals

public boolean equals(java.lang.Object object)
Specified by:
equals in interface java.util.Collection
Specified by:
equals in interface java.util.Set
Overrides:
equals in class java.lang.Object

removeAll

public boolean removeAll(java.util.Collection collection)
Specified by:
removeAll in interface java.util.Collection
Specified by:
removeAll in interface java.util.Set

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.

toString

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

addAll

public boolean addAll(java.util.Collection collection)
Specified by:
addAll in interface java.util.Collection
Specified by:
addAll in interface java.util.Set

toArray

public java.lang.Object[] toArray(java.lang.Object[] objectArray)
Returns the variables in this clique as an array. If the clique is not modified, then the ordering will remain consistent across calls.

Specified by:
toArray in interface java.util.Collection
Specified by:
toArray in interface java.util.Set

toArray

public java.lang.Object[] toArray()
Returns the variables in this clique as an array. If the clique is not modified, then the ordering will remain consistent across calls.

Specified by:
toArray in interface java.util.Collection
Specified by:
toArray in interface java.util.Set

containsAll

public boolean containsAll(java.util.Collection collection)
Specified by:
containsAll in interface java.util.Collection
Specified by:
containsAll in interface java.util.Set

retainAll

public boolean retainAll(java.util.Collection collection)
Specified by:
retainAll in interface java.util.Collection
Specified by:
retainAll in interface java.util.Set

clone

public java.lang.Object clone()
Overrides:
clone in class java.lang.Object

add

public boolean add(java.lang.Object object)
Specified by:
add in interface java.util.Collection
Specified by:
add in interface java.util.Set

add

public boolean add(java.lang.Object object,
                   boolean checkSorted)

contains

public boolean contains(java.lang.Object object)
Specified by:
contains in interface java.util.Collection
Specified by:
contains in interface java.util.Set

size

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

weight

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

Specified by:
weight in interface VarSet

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

remove

public boolean remove(java.lang.Object object)
Specified by:
remove in interface java.util.Collection
Specified by:
remove in interface java.util.Set

clear

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

isEmpty

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

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