Modifier and Type | Class and 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.
|
Modifier and Type | Field and Description |
---|---|
private java.util.Map<K,java.util.Set<V>> |
map
The backing map.
|
java.util.List<java.lang.Integer> |
marks
The marks/checkpoints that have been set so far, to permit restoring to a previous state.
|
private java.util.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 and Description |
---|
CheckpointingMultiMap() |
Modifier and Type | Method and Description |
---|---|
private void |
add_bare(K key,
V value) |
boolean |
add(K key,
V value)
Precondition: the mapping key→value is not already in the map.
|
boolean |
containsKey(@UnknownSignedness java.lang.Object key)
Returns true if this map contains the given key.
|
java.util.Set<V> |
getValues(K key)
Returns the values that the given key maps to.
|
java.util.Set<K> |
keySet()
Returns the set of keys in this map (the domain).
|
void |
mark()
Checkpoint the state of the data structure, for use by
undoToLastMark() . |
private void |
remove_bare(K key,
V value) |
boolean |
remove(K key,
V value)
Precondition: the mapping key→value is in the map.
|
int |
size()
Returns the size of this map: the number of mappings.
|
java.lang.String |
toString()
Returns a String representation of this map.
|
private void |
undoLastOp() |
void |
undoToLastMark()
Undo changes since the last call to
mark() . |
public static boolean verbose_log
public final java.util.List<java.lang.Integer> marks
private final java.util.List<CheckpointingMultiMap.OpKeyVal> ops
private int steps
public boolean add(K key, V value)
IMultiMap
public boolean remove(K key, V value)
IMultiMap
public void mark()
undoToLastMark()
.public void undoToLastMark()
mark()
.private void undoLastOp()
public java.util.Set<V> getValues(K key)
IMultiMap
public boolean containsKey(@UnknownSignedness java.lang.Object key)
key
- the key to look forpublic java.util.Set<K> keySet()
IMultiMap
public int size()
IMultiMap