blog
Class DefaultObjectSet

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

public class DefaultObjectSet
extends AbstractObjectSet

ObjectSet implementation that can be constructed using an ordinary Collection. A DefaultObjectSet is not backed by this collection; it just reflects the contents of that collection at the time of construction.


Field Summary
 
Fields inherited from interface blog.ObjectSet
EMPTY_OBJECT_SET, UNDETERMINED_SET
 
Constructor Summary
DefaultObjectSet(java.util.Collection c)
          Creates an ObjectSet whose contents are the same as the current contents of the given collection.
 
Method Summary
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.
 
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, toString
 
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

DefaultObjectSet

public DefaultObjectSet(java.util.Collection c)
Creates an ObjectSet whose contents are the same as the current contents of the given collection.

Method Detail

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

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.


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.


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.