blog
Class POPAppBasedSet

java.lang.Object
  extended by java.util.AbstractCollection<E>
      extended by java.util.AbstractSet
          extended by blog.AbstractObjectSet
              extended by blog.POPAppBasedSet
All Implemented Interfaces:
ObjectSet, java.lang.Iterable, java.util.Collection, java.util.Set

public class POPAppBasedSet
extends AbstractObjectSet

ObjectSet implementation that is composed of individual objects, plus all the objects that satisfy certain potential object pattern (POP) applications (number variables), with certain exceptional objects excluded.


Field Summary
 
Fields inherited from interface blog.ObjectSet
EMPTY_OBJECT_SET, UNDETERMINED_SET
 
Constructor Summary
POPAppBasedSet()
           
 
Method Summary
 void addIndividual(java.lang.Object indiv, NumberVar popApp)
          Adds the given individual to this set, asserting that the individual satisfies the POP application governed by the given number variable (or no POP application if the number variable is null).
 void addSatisfiers(NumberVar popApp, ObjectSet satisfiers, java.util.Set newExceptions)
          Adds the given POP application satisfier set as a subset of this set, with the given exceptions.
protected  java.lang.Boolean containsInternal(java.lang.Object o)
          Returns Boolean.TRUE if this set contains obj, Boolean.FALSE if this set does not contain obj, and null if the underlying partial world is not complete enough to make the distinction.
 ObjectSet getExplicitVersion()
          Returns a version of this set that no longer reflects changes to the partial world or evaluation context.
 int indexOf(java.lang.Object o)
          Returns the number which, when passed to sample, will yield the given element of this set.
 ObjectIterator iterator(java.util.Set externallyDistinguished)
          Returns an ObjectIterator whose skipIndistinguishable method treats all of the given objects as distinguishable from all other objects, even if they are indistinguishable in the underlying partial world.
 java.lang.Object sample(int n)
          Returns an object sampled uniformly at random from this set, assuming that the given number n is sampled uniformly from the numbers 0, ..., size - 1 (where size is the size of this set).
protected  java.lang.Integer sizeInternal()
          Returns the size of this set, or null if the underlying partial world is not complete enough to determine the size.
 java.lang.String toString()
           
 
Methods inherited from class blog.AbstractObjectSet
canDetermineContains, canDetermineElements, canDetermineIsEmpty, canDetermineSize, contains, isEmpty, isEmptyInternal, iterator, singleton, size
 
Methods inherited from class java.util.AbstractSet
equals, hashCode, removeAll
 
Methods inherited from class java.util.AbstractCollection
add, addAll, clear, 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
add, addAll, clear, containsAll, equals, hashCode, remove, removeAll, retainAll, toArray, toArray
 

Constructor Detail

POPAppBasedSet

public POPAppBasedSet()
Method Detail

addIndividual

public void addIndividual(java.lang.Object indiv,
                          NumberVar popApp)
Adds the given individual to this set, asserting that the individual satisfies the POP application governed by the given number variable (or no POP application if the number variable is null). This does nothing if the given POP application is already in this set and the given individual is not an exception. If the given individual is currently in the exception set for its POP application, it is removed from that exception set.


addSatisfiers

public void addSatisfiers(NumberVar popApp,
                          ObjectSet satisfiers,
                          java.util.Set newExceptions)
Adds the given POP application satisfier set as a subset of this set, with the given exceptions. The exceptions set must be a subset of the given satisfier set. If the given POP application was already a subset of this set, then the new exceptions set is the intersection of the given exceptions set with the old one. Otherwise, the exceptions set is the given one minus any individual elements of this set that satisfy the given POP application.


sizeInternal

protected java.lang.Integer sizeInternal()
Description copied from class: AbstractObjectSet
Returns the size of this set, or null if the underlying partial world is not complete enough to determine the size.

Specified by:
sizeInternal in class AbstractObjectSet

containsInternal

protected java.lang.Boolean containsInternal(java.lang.Object o)
Description copied from class: AbstractObjectSet
Returns Boolean.TRUE if this set contains obj, Boolean.FALSE if this set does not contain obj, and null if the underlying partial world is not complete enough to make the distinction.

Specified by:
containsInternal in class AbstractObjectSet

iterator

public ObjectIterator iterator(java.util.Set externallyDistinguished)
Description copied from interface: ObjectSet
Returns an ObjectIterator whose skipIndistinguishable method treats all of the given objects as distinguishable from all other objects, even if they are indistinguishable in the underlying partial world. These externally distinguishable objects are typically the values of logical variables in the current scope -- the point is that even if the partial world makes the same assertions about two objects, these objects may satisfy different formulas if one is the value of a currently bound variable and one is not.


getExplicitVersion

public ObjectSet getExplicitVersion()
Description copied from interface: ObjectSet
Returns a version of this set that no longer reflects changes to the partial world or evaluation context. It may still be backed by a world's POP application satisfier sets (so that new identifiers are added properly), but other than that, its methods will not call any methods on the underlying partial world.

This method returns null if the underlying partial world is not complete enough to construct an explicit version of this set.


sample

public java.lang.Object sample(int n)
Description copied from interface: ObjectSet
Returns an object sampled uniformly at random from this set, assuming that the given number n is sampled uniformly from the numbers 0, ..., size - 1 (where size is the size of this set).

If the underlying partial world is not complete enough to fully define this set, this method returns null.


indexOf

public int indexOf(java.lang.Object o)
Description copied from interface: ObjectSet
Returns the number which, when passed to sample, will yield the given element of this set. If the given object is not in this set, returns -1.

If the underlying partial world is not complete enough to fully define this set, this method returns -1.


toString

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