Package daikon.inv

Class ValueSet

  • All Implemented Interfaces:
    Serializable, Cloneable
    Direct Known Subclasses:
    ValueSet.ValueSetFloat, ValueSet.ValueSetFloatArray, ValueSet.ValueSetScalar, ValueSet.ValueSetScalarArray, ValueSet.ValueSetString, ValueSet.ValueSetStringArray

    public abstract class ValueSet
    extends LimitedSizeLongSet
    implements Serializable, Cloneable
    ValueSet stores a set of values. The implementation only stores integers. When adding a value, for efficiency its hash code is added rather than the value itself. If the set size exceeds a specified limit, then its rep is nulled.

    The size of this class is used for efficient justification tests.

    Relevant subclasses are:

    • ValueSetScalar
    • ValueSetFloat
    • ValueSetScalarArray
    • ValueSetFloatArray
    • ValueSetString
    • ValueSetStringArray
    These subclasses store a hashcode.

    Caveat: The size is an approximation, because if two values happen to have the same hash value, then the sets size reflects only one of them. (As an example, the hash codes of 0L and -1L are the same. This implementation has a special case to avoid that problem for long values, but the hash codes of the arrays {0L} and {-1L} are also the same and this implementation does not work around that problem.)

    An alternative approach would be to store actual values, rather than approximating. That would use more space than the current implementation does, but it would give a more accurate approximation of the size, Here are some possible implementation approaches:

    • use a TreeSet with a special comparator
    • use a HashSet that stores wrappers, where the wrappers redefine hashCode. (That is necessary because arrays don't override Object.hashCode.
    See Also:
    Serialized Form
    • Constructor Detail

      • ValueSet

        protected ValueSet​(int max_values)
    • Method Detail

      • add

        public abstract void add​(Object v1)
        Add the specified object (really, its hashcode) to the set.
      • add_stats

        protected abstract void add_stats​(ValueSet other)
        Add stats from the specified value set.
      • repr_short

        public abstract String repr_short()
        Returns a short description of the values seen.