Package randoop.util

Class CheckpointingMultiMap<K extends @Signed Object,​V extends @Signed Object>

  • All Implemented Interfaces:
    IMultiMap<K,​V>

    public class CheckpointingMultiMap<K extends @Signed Object,​V extends @Signed Object>
    extends Object
    implements IMultiMap<K,​V>
    A MultiMap that supports checkpointing and restoring to a checkpoint (that is, undoing all operations up to a checkpoint, also called a "mark").
    • Field Detail

      • verbose_log

        public static boolean verbose_log
        True if this class should do logging.
      • map

        private final Map<K extends @Signed Object,​Set<V extends @Signed Object>> map
        The backing map.
      • marks

        public final List<Integer> marks
        The marks/checkpoints that have been set so far, to permit restoring to a previous state.
      • steps

        private int steps
        The number of operations that have been performed on this map.
    • Constructor Detail

      • CheckpointingMultiMap

        public CheckpointingMultiMap()
    • Method Detail

      • add

        public boolean add​(K key,
                           V value)
        Description copied from interface: IMultiMap
        Precondition: the mapping key→value is not already in the map.
        Specified by:
        add in interface IMultiMap<K extends @Signed Object,​V extends @Signed Object>
        Parameters:
        key - cannot be null
        value - cannot be null
        Returns:
        true if the call modifies this object
      • add_bare

        private void add_bare​(K key,
                              V value)
      • remove

        public boolean remove​(K key,
                              V value)
        Description copied from interface: IMultiMap
        Precondition: the mapping key→value is in the map.
        Specified by:
        remove in interface IMultiMap<K extends @Signed Object,​V extends @Signed Object>
        Parameters:
        key - cannot be null
        value - cannot be null
        Returns:
        true if the call modifies this object
      • remove_bare

        private void remove_bare​(K key,
                                 V value)
      • mark

        public void mark()
        Checkpoint the state of the data structure, for use by undoToLastMark().
      • undoToLastMark

        public void undoToLastMark()
        Undo changes since the last call to mark().
      • undoLastOp

        private void undoLastOp()
      • getValues

        public Set<V> getValues​(K key)
        Description copied from interface: IMultiMap
        Returns the values that the given key maps to.
        Specified by:
        getValues in interface IMultiMap<K extends @Signed Object,​V extends @Signed Object>
        Parameters:
        key - cannot be null
        Returns:
        the set of values for the given key
      • containsKey

        public boolean containsKey​(@UnknownSignedness Object key)
        Returns true if this map contains the given key.
        Parameters:
        key - the key to look for
        Returns:
        true if this map contains the given key
      • keySet

        public Set<K> keySet()
        Description copied from interface: IMultiMap
        Returns the set of keys in this map (the domain).
        Specified by:
        keySet in interface IMultiMap<K extends @Signed Object,​V extends @Signed Object>
        Returns:
        the set of keys in this map
      • size

        public int size()
        Description copied from interface: IMultiMap
        Returns the size of this map: the number of mappings.
        Specified by:
        size in interface IMultiMap<K extends @Signed Object,​V extends @Signed Object>
        Returns:
        the number of entries in this map
      • toString

        public String toString()
        Description copied from interface: IMultiMap
        Returns a String representation of this map.
        Specified by:
        toString in interface IMultiMap<K extends @Signed Object,​V extends @Signed Object>
        Overrides:
        toString in class Object
        Returns:
        a String representation of this map