Package proguard.analysis.cpa.defaults
Class DifferentialMap<K,V>
- java.lang.Object
-
- proguard.analysis.cpa.defaults.DifferentialMap<K,V>
-
- All Implemented Interfaces:
java.util.Map<K,V>
- Direct Known Subclasses:
DifferentialMapAbstractState
public class DifferentialMap<K,V> extends java.lang.Object implements java.util.Map<K,V>
A differential representation of maps. Maps are stored as trees with full maps as roots and action nodes. Action nodes define either element deletion or insertion. The value of the map is defined as the root map with action nodes between it and the current node applied to it. Any action node can be used to form a root of another tree with an equivalent semantic. A predicate on when to collapse can be provided for creating root nodes automatically upon insertion or removal.
-
-
Field Summary
Fields Modifier and Type Field Description protected java.util.function.Predicate<DifferentialMap<K,V>>
shouldCollapse
-
Constructor Summary
Constructors Constructor Description DifferentialMap()
Create an empty differential map.DifferentialMap(java.util.Map<K,V> m)
Create a differential map from another map.DifferentialMap(java.util.Map<K,V> m, java.util.function.Predicate<DifferentialMap<K,V>> shouldCollapse)
Create a differential map from another map and a collapse criterion.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
clear()
void
collapse()
Changes the internal representation by applying action nodes to a copy of the root.boolean
containsKey(java.lang.Object key)
boolean
containsValue(java.lang.Object value)
@NotNull java.util.Set<java.util.Map.Entry<K,V>>
entrySet()
boolean
equals(java.lang.Object obj)
V
get(java.lang.Object key)
int
getDepth()
Returns the depth of the action node with regard to the root map.int
hashCode()
boolean
isEmpty()
@NotNull java.util.Set<K>
keySet()
V
put(K key, V value)
void
putAll(@NotNull java.util.Map<? extends K,? extends V> m)
V
remove(java.lang.Object key)
int
size()
@NotNull java.util.Collection<V>
values()
-
-
-
Field Detail
-
shouldCollapse
protected final java.util.function.Predicate<DifferentialMap<K,V>> shouldCollapse
-
-
Constructor Detail
-
DifferentialMap
public DifferentialMap()
Create an empty differential map.
-
DifferentialMap
public DifferentialMap(java.util.Map<K,V> m)
Create a differential map from another map.- Parameters:
m
- initial map if it is a differential map, the collapse criterion will be copied from it
-
DifferentialMap
public DifferentialMap(java.util.Map<K,V> m, java.util.function.Predicate<DifferentialMap<K,V>> shouldCollapse)
Create a differential map from another map and a collapse criterion.- Parameters:
m
- initial mapshouldCollapse
- whether the map should collapse into a root node
-
-
Method Detail
-
collapse
public void collapse()
Changes the internal representation by applying action nodes to a copy of the root.
-
getDepth
public int getDepth()
Returns the depth of the action node with regard to the root map.
-
containsKey
public boolean containsKey(java.lang.Object key)
-
containsValue
public boolean containsValue(java.lang.Object value)
-
keySet
@NotNull public @NotNull java.util.Set<K> keySet()
-
values
@NotNull public @NotNull java.util.Collection<V> values()
-
hashCode
public int hashCode()
-
-