jpaul.Constraints.SetConstraints
Class SVar<T>

java.lang.Object
  extended by jpaul.Constraints.Var<java.util.Set<T>>
      extended by jpaul.Constraints.SetConstraints.SVar<T>

public class SVar<T>
extends Var<java.util.Set<T>>

SVar is a variable whose values are sets of Ts.

Version:
$Id: SVar.java,v 1.7 2006/03/14 02:29:30 salcianu Exp $
Author:
Alexandru Salcianu - salcianu@alum.mit.edu

Field Summary
 
Fields inherited from class jpaul.Constraints.Var
id
 
Constructor Summary
SVar()
          Creates an SVar using a HashSet factory (SetFacts.hash)
SVar(SetFactory<T> setFact)
          Creates an SVar.
 
Method Summary
 java.util.Set<T> copy(java.util.Set<T> s)
          Returns a set that contains the same elements as s.
 boolean join(java.util.Set<T> s1, java.util.Set<T> s2)
          Adds all the elements from s2 to s1.
 java.lang.String toString()
          String representation of this variable.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

SVar

public SVar(SetFactory<T> setFact)
Creates an SVar.

Parameters:
setFact - Set factory used internally by the copy method. For a set constraint systems with a few large sets, a HashSet factory (SetFacts.hash) is a safe choice; in other cases, you may gain significant speed by using more appropriate set factories.

SVar

public SVar()
Creates an SVar using a HashSet factory (SetFacts.hash)

See Also:
SVar(SetFactory)
Method Detail

toString

public java.lang.String toString()
Description copied from class: Var
String representation of this variable. The default implementation returns "Vid" where id is a unique integer id.

Overrides:
toString in class Var<java.util.Set<T>>

copy

public java.util.Set<T> copy(java.util.Set<T> s)
Returns a set that contains the same elements as s. Constructs the new set using the set factory passed to the constructor.

Specified by:
copy in class Var<java.util.Set<T>>

join

public boolean join(java.util.Set<T> s1,
                    java.util.Set<T> s2)
Adds all the elements from s2 to s1.

Specified by:
join in class Var<java.util.Set<T>>
Returns:
true iff the x changed after y was joined to it. A false result means that x was already bigger than y. Hence, this operation implictly defines the order relation in the lattice where this variable takes values.


Copyright 2005 Alexandru Salcianu - salcianu@alum.mit.edu