cc.mallet.grmm.types
Class ListVarSet

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

public class ListVarSet
extends java.util.AbstractSet
implements VarSet, java.io.Serializable

A clique that uses very little time and memory based on the flyweight pattern, in the same way as BitVarSet. This implementation uses an ArrayList of indices, and is likely to be more memory-efficient when the Universe is very, very large.

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

Constructor Summary
ListVarSet(Universe universe, java.util.Collection included)
           
ListVarSet(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 equals(java.lang.Object o)
           
 Variable get(int idx)
          Returns the variable in this clique at index idx.
 int hashCode()
           
 VarSet intersection(VarSet c)
          Returns the intersection of two cliques.
 boolean isEmpty()
           
 java.util.Iterator iterator()
           
 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
removeAll
 
Methods inherited from class java.util.AbstractCollection
addAll, containsAll, 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, containsAll, remove, removeAll, retainAll, toArray, toArray
 

Constructor Detail

ListVarSet

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

ListVarSet

public ListVarSet(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

equals

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

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

intersection

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

Specified by:
intersection in interface VarSet

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

toString

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