Package randoop.util
Class CheckpointingMultiMap<K extends @Signed Object,V extends @Signed Object>
- java.lang.Object
-
- randoop.util.CheckpointingMultiMap<K,V>
-
- 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").
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private class
CheckpointingMultiMap.OpKeyVal
A triple of an operation, a key, and a value.private static class
CheckpointingMultiMap.Ops
The operations on the map.
-
Field Summary
Fields Modifier and Type Field Description private Map<K,Set<V>>
map
The backing map.List<Integer>
marks
The marks/checkpoints that have been set so far, to permit restoring to a previous state.private List<CheckpointingMultiMap.OpKeyVal>
ops
The operations that have been performed on this map.private int
steps
The number of operations that have been performed on this map.static boolean
verbose_log
True if this class should do logging.
-
Constructor Summary
Constructors Constructor Description CheckpointingMultiMap()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
add(K key, V value)
Precondition: the mapping key→value is not already in the map.private void
add_bare(K key, V value)
boolean
containsKey(@UnknownSignedness Object key)
Returns true if this map contains the given key.Set<V>
getValues(K key)
Returns the values that the given key maps to.Set<K>
keySet()
Returns the set of keys in this map (the domain).void
mark()
Checkpoint the state of the data structure, for use byundoToLastMark()
.boolean
remove(K key, V value)
Precondition: the mapping key→value is in the map.private void
remove_bare(K key, V value)
int
size()
Returns the size of this map: the number of mappings.String
toString()
Returns a String representation of this map.private void
undoLastOp()
void
undoToLastMark()
Undo changes since the last call tomark()
.
-
-
-
Field Detail
-
verbose_log
public static boolean verbose_log
True if this class should do logging.
-
marks
public final List<Integer> marks
The marks/checkpoints that have been set so far, to permit restoring to a previous state.
-
ops
private final List<CheckpointingMultiMap.OpKeyVal> ops
The operations that have been performed on this map.
-
steps
private int steps
The number of operations that have been performed on this map.
-
-
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.
-
remove
public boolean remove(K key, V value)
Description copied from interface:IMultiMap
Precondition: the mapping key→value is in the map.
-
mark
public void mark()
Checkpoint the state of the data structure, for use byundoToLastMark()
.
-
undoToLastMark
public void undoToLastMark()
Undo changes since the last call tomark()
.
-
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.
-
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).
-
size
public int size()
Description copied from interface:IMultiMap
Returns the size of this map: the number of mappings.
-
-