kodkod.engine.satlab
Class TraceSet

java.lang.Object
  extended by java.util.AbstractCollection<E>
      extended by java.util.AbstractSet<Clause>
          extended by kodkod.engine.satlab.TraceSet
All Implemented Interfaces:
java.lang.Iterable<Clause>, java.util.Collection<Clause>, java.util.Set<Clause>

public final class TraceSet
extends java.util.AbstractSet<Clause>

A set implementation that efficiently stores clauses belonging to a given ResolutionTrace. This is not a general purpose set implementation. In particular, the behavior of an instance of this class is undefined if any of its methods that take a Clause or Object argument are called with a Clause that is not a member of the trace with which the instance was constructed.

Author:
Emina Torlak
specfield:
trace: ResolutionTrace
clauses: set trace.conflict.*antecedents

Constructor Summary
TraceSet(ResolutionTrace trace)
          Constructs a clause set for the clauses from the given resolution trace.
 
Method Summary
 boolean add(Clause o)
          Adds the given member of this.trace to this.clauses if not already present and returns true.
 void clear()
          Removes all clauses from this.clauses.
 boolean contains(java.lang.Object o)
          Returns true if this.clauses contains the given member of this.trace.
 java.util.Iterator<Clause> iterator()
          Returns an iterator over this.clauses.
 boolean remove(java.lang.Object o)
          Removes the given member of this.trace from this.clauses if present and returns true.
 int size()
          Returns the cardinality of this.clauses.
 
Methods inherited from class java.util.AbstractSet
equals, hashCode, removeAll
 
Methods inherited from class java.util.AbstractCollection
addAll, containsAll, isEmpty, retainAll, toArray, toArray, toString
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.Set
addAll, containsAll, isEmpty, retainAll, toArray, toArray
 

Constructor Detail

TraceSet

public TraceSet(ResolutionTrace trace)
Constructs a clause set for the clauses from the given resolution trace.

effects:
this.trace' = trace && no this.clauses'
Method Detail

add

public boolean add(Clause o)
Adds the given member of this.trace to this.clauses if not already present and returns true. Otherwise does nothing and returns false.

Specified by:
add in interface java.util.Collection<Clause>
Specified by:
add in interface java.util.Set<Clause>
Overrides:
add in class java.util.AbstractCollection<Clause>
Returns:
this.clauses' != this.clauses
effects:
this.clauses' = this.clauses + o
requires:
o in this.trace.conflict.*antecedents

clear

public void clear()
Removes all clauses from this.clauses.

Specified by:
clear in interface java.util.Collection<Clause>
Specified by:
clear in interface java.util.Set<Clause>
Overrides:
clear in class java.util.AbstractCollection<Clause>
effects:
no this.clauses'

contains

public boolean contains(java.lang.Object o)
Returns true if this.clauses contains the given member of this.trace.

Specified by:
contains in interface java.util.Collection<Clause>
Specified by:
contains in interface java.util.Set<Clause>
Overrides:
contains in class java.util.AbstractCollection<Clause>
Returns:
o in this.clauses
requires:
o in this.trace.conflict.*antecedents

iterator

public java.util.Iterator<Clause> iterator()
Returns an iterator over this.clauses. Note that the returned iterator may not behave correctly if there has been an attempt to add a Clause not in this.trace.conflict.*antecedents to this.clauses.

Specified by:
iterator in interface java.lang.Iterable<Clause>
Specified by:
iterator in interface java.util.Collection<Clause>
Specified by:
iterator in interface java.util.Set<Clause>
Specified by:
iterator in class java.util.AbstractCollection<Clause>
Returns:
an iterator over this.clauses.

remove

public boolean remove(java.lang.Object o)
Removes the given member of this.trace from this.clauses if present and returns true. Otherwise does nothing and returns false.

Specified by:
remove in interface java.util.Collection<Clause>
Specified by:
remove in interface java.util.Set<Clause>
Overrides:
remove in class java.util.AbstractCollection<Clause>
Returns:
this.clauses' != this.clauses
effects:
this.clauses' = this.clauses - o
requires:
o in this.trace.conflict.*antecedents

size

public int size()
Returns the cardinality of this.clauses.

Specified by:
size in interface java.util.Collection<Clause>
Specified by:
size in interface java.util.Set<Clause>
Specified by:
size in class java.util.AbstractCollection<Clause>
Returns:
#this.clauses