pub struct AccessPathTrie<T: FootprintDomain>(_);
Expand description

Set of (root node, child) associations

Implementations§

source§

impl<T: FootprintDomain> AccessPathTrie<T>

source

pub fn remove_node(&mut self, ap: AccessPath) -> Option<TrieNode<T>>

Removes node located at the given access path Returns the node if it has been fully removed from the trie (i.e. it did not have any children)

source

pub fn get_child_data(&self) -> Option<T>

source

pub fn update_access_path_weak(&mut self, ap: AccessPath, data: Option<T>)

Like update_access_path, but always performs a weak update

source

pub fn update_access_path(&mut self, ap: AccessPath, data: Option<T>)

Update ap in global. Performs a strong update if the base of ap is a local and all offsets are Field’s. Otherwise, performs a weak update (TODO: more details). Creates nodes for each offset in ap if they do not already exist

source

pub fn join_access_path(&mut self, ap: AccessPath, node: TrieNode<T>)

Join the value bound to ap with node

source

pub fn bind_local( &mut self, local_index: TempIndex, data: T, fun_env: &FunctionEnv<'_> )

Bind data to local_index in the trie, overwriting the old value of local_index

source

pub fn bind_local_node( &mut self, local_index: TempIndex, node: TrieNode<T>, fun_env: &FunctionEnv<'_> )

Bind node to local_index in the trie, overwriting the old value of local_index

source

pub fn remove_local(&mut self, local_index: TempIndex, fun_env: &FunctionEnv<'_>)

Remove the value bound to the local variable local_index

source

pub fn bind_return(&mut self, return_index: usize, data: T)

Bind data to the return variable return_index

source

pub fn get_local( &self, local_index: TempIndex, fun_env: &FunctionEnv<'_> ) -> Option<&T>

Retrieve the data associated with local_index in the trie. Returns None if there is no associated data

source

pub fn get_local_node( &self, local_index: TempIndex, fun_env: &FunctionEnv<'_> ) -> Option<&TrieNode<T>>

Retrieve the node associated with local_index in the trie. Returns None if there is no associated node

source

pub fn local_exists( &self, local_index: TempIndex, fun_env: &FunctionEnv<'_> ) -> bool

Return true if there is a value bound to local variable local_index

source

pub fn keys_statically_known(&self) -> bool

Return true if the keys of self have no dynamic components and thus can be converted into a compact set of concrete access paths.

source

pub fn substitute_footprint<F>( self, actuals: &[TempIndex], type_actuals: &[Type], func_env: &FunctionEnv<'_>, sub_map: &dyn AccessPathMap<AbsAddr>, sub_data: F ) -> Selfwhere F: FnMut(&mut T, &[TempIndex], &[Type], &FunctionEnv<'_>, &dyn AccessPathMap<AbsAddr>) + Copy,

Bind caller data in actuals, type_actuals, and sub_map to self. (1) Bind all free type variables in self to type_actuals (2) Apply sub_data to self.data and (recursively) to the data fields of self.children

source

pub fn substitute_footprint_skip_data( self, actuals: &[TempIndex], type_actuals: &[Type], func_env: &FunctionEnv<'_>, sub_map: &dyn AccessPathMap<AbsAddr> ) -> Self

Same as substitute_footprint, but does not change the data field of any node

source

pub fn substitute_footprint_concrete( self, actuals: &[TempIndex], type_actuals: &[TypeTag], func_env: &FunctionEnv<'_>, sub_map: &dyn AccessPathMap<AbsAddr>, env: &GlobalEnv ) -> Self

Substitute concrete values actuals and type_actuals into self

source

pub fn iter_values<F>(&mut self, f: F)where F: FnMut(&mut TrieNode<T>) + Copy,

Apply f to each node in self

source

pub fn iter_offsets<F>(&self, f: F)where F: FnMut(&Offset),

Apply f to each offset in self

source

pub fn iter_paths_opt<F>(&self, f: F)where F: FnMut(&AccessPath, &Option<&T>),

Apply f to each (access path, Option(data)) pair encoded in self

source

pub fn iter_paths<F>(&self, f: F)where F: FnMut(&AccessPath, &T),

Apply f to each (access path, data) pair encoded in self

source

pub fn filter_map_paths<F, R>(&self, f: F) -> Vec<R> where F: FnMut(&AccessPath, &T) -> Option<R>,

Apply f to each (access path, data) pair encoded in self and collects the result when f returns Some(r)

source

pub fn display<'a>( &'a self, env: &'a FunctionEnv<'_> ) -> AccessPathTrieDisplay<'a, T>

Return a wrapper that of self that implements Display using env

Methods from Deref<Target = MapDomain<Root, TrieNode<T>>>§

source

pub fn insert_join(&mut self, k: K, v: V) -> JoinResult

Join v with self[k] if k is bound, insert v otherwise

source

pub fn update_values(&mut self, f: impl FnMut(&mut V))

Updates the values in the range of the map using the given function. Notice that with other kind of map representations we would use iter_mut for this, but this is not available in OrdMap for obvious reasons (because entries are shared), so we need to use this pattern here instead.

Methods from Deref<Target = OrdMap<K, V>>§

pub fn is_empty(&self) -> bool

Test whether a map is empty.

Time: O(1)

Examples
assert!(
  !ordmap!{1 => 2}.is_empty()
);
assert!(
  OrdMap::<i32, i32>::new().is_empty()
);

pub fn ptr_eq(&self, other: &OrdMap<K, V>) -> bool

Test whether two maps refer to the same content in memory.

This is true if the two sides are references to the same map, or if the two maps refer to the same root node.

This would return true if you’re comparing a map to itself, or if you’re comparing a map to a fresh clone of itself.

Time: O(1)

pub fn len(&self) -> usize

Get the size of a map.

Time: O(1)

Examples
assert_eq!(3, ordmap!{
  1 => 11,
  2 => 22,
  3 => 33
}.len());

pub fn clear(&mut self)

Discard all elements from the map.

This leaves you with an empty map, and all elements that were previously inside it are dropped.

Time: O(n)

Examples
let mut map = ordmap![1=>1, 2=>2, 3=>3];
map.clear();
assert!(map.is_empty());

pub fn get_max(&self) -> Option<&(K, V)>

Get the largest key in a map, along with its value. If the map is empty, return None.

Time: O(log n)

Examples
assert_eq!(Some(&(3, 33)), ordmap!{
  1 => 11,
  2 => 22,
  3 => 33
}.get_max());

pub fn get_min(&self) -> Option<&(K, V)>

Get the smallest key in a map, along with its value. If the map is empty, return None.

Time: O(log n)

Examples
assert_eq!(Some(&(1, 11)), ordmap!{
  1 => 11,
  2 => 22,
  3 => 33
}.get_min());

pub fn iter(&self) -> Iter<'_, K, V>

Get an iterator over the key/value pairs of a map.

pub fn range<R, BK>(&self, range: R) -> Iter<'_, K, V>where R: RangeBounds<BK>, K: Borrow<BK>, BK: Ord + ?Sized,

Create an iterator over a range of key/value pairs.

pub fn keys(&self) -> Keys<'_, K, V>

Get an iterator over a map’s keys.

pub fn values(&self) -> Values<'_, K, V>

Get an iterator over a map’s values.

pub fn diff<'a>(&'a self, other: &'a OrdMap<K, V>) -> DiffIter<'a, K, V>

Get an iterator over the differences between this map and another, i.e. the set of entries to add, update, or remove to this map in order to make it equal to the other map.

This function will avoid visiting nodes which are shared between the two maps, meaning that even very large maps can be compared quickly if most of their structure is shared.

Time: O(n) (where n is the number of unique elements across the two maps, minus the number of elements belonging to nodes shared between them)

pub fn get<BK>(&self, key: &BK) -> Option<&V>where BK: Ord + ?Sized, K: Borrow<BK>,

Get the value for a key from a map.

Time: O(log n)

Examples
let map = ordmap!{123 => "lol"};
assert_eq!(
  map.get(&123),
  Some(&"lol")
);

pub fn get_key_value<BK>(&self, key: &BK) -> Option<(&K, &V)>where BK: Ord + ?Sized, K: Borrow<BK>,

Get the key/value pair for a key from a map.

Time: O(log n)

Examples
let map = ordmap!{123 => "lol"};
assert_eq!(
  map.get_key_value(&123),
  Some((&123, &"lol"))
);

pub fn get_prev<BK>(&self, key: &BK) -> Option<(&K, &V)>where BK: Ord + ?Sized, K: Borrow<BK>,

Get the closest smaller entry in a map to a given key as a mutable reference.

If the map contains the given key, this is returned. Otherwise, the closest key in the map smaller than the given value is returned. If the smallest key in the map is larger than the given key, None is returned.

Examples
let map = ordmap![1 => 1, 3 => 3, 5 => 5];
assert_eq!(Some((&3, &3)), map.get_prev(&4));

pub fn get_next<BK>(&self, key: &BK) -> Option<(&K, &V)>where BK: Ord + ?Sized, K: Borrow<BK>,

Get the closest larger entry in a map to a given key as a mutable reference.

If the set contains the given value, this is returned. Otherwise, the closest value in the set larger than the given value is returned. If the largest value in the set is smaller than the given value, None is returned.

Examples
let map = ordmap![1 => 1, 3 => 3, 5 => 5];
assert_eq!(Some((&5, &5)), map.get_next(&4));

pub fn contains_key<BK>(&self, k: &BK) -> boolwhere BK: Ord + ?Sized, K: Borrow<BK>,

Test for the presence of a key in a map.

Time: O(log n)

Examples
let map = ordmap!{123 => "lol"};
assert!(
  map.contains_key(&123)
);
assert!(
  !map.contains_key(&321)
);

pub fn is_submap_by<B, RM, F>(&self, other: RM, cmp: F) -> boolwhere F: FnMut(&V, &B) -> bool, RM: Borrow<OrdMap<K, B>>,

Test whether a map is a submap of another map, meaning that all keys in our map must also be in the other map, with the same values.

Use the provided function to decide whether values are equal.

Time: O(n log n)

pub fn is_proper_submap_by<B, RM, F>(&self, other: RM, cmp: F) -> boolwhere F: FnMut(&V, &B) -> bool, RM: Borrow<OrdMap<K, B>>,

Test whether a map is a proper submap of another map, meaning that all keys in our map must also be in the other map, with the same values. To be a proper submap, ours must also contain fewer keys than the other map.

Use the provided function to decide whether values are equal.

Time: O(n log n)

pub fn is_submap<RM>(&self, other: RM) -> boolwhere V: PartialEq<V>, RM: Borrow<OrdMap<K, V>>,

Test whether a map is a submap of another map, meaning that all keys in our map must also be in the other map, with the same values.

Time: O(n log n)

Examples
let map1 = ordmap!{1 => 1, 2 => 2};
let map2 = ordmap!{1 => 1, 2 => 2, 3 => 3};
assert!(map1.is_submap(map2));

pub fn is_proper_submap<RM>(&self, other: RM) -> boolwhere V: PartialEq<V>, RM: Borrow<OrdMap<K, V>>,

Test whether a map is a proper submap of another map, meaning that all keys in our map must also be in the other map, with the same values. To be a proper submap, ours must also contain fewer keys than the other map.

Time: O(n log n)

Examples
let map1 = ordmap!{1 => 1, 2 => 2};
let map2 = ordmap!{1 => 1, 2 => 2, 3 => 3};
assert!(map1.is_proper_submap(map2));

let map3 = ordmap!{1 => 1, 2 => 2};
let map4 = ordmap!{1 => 1, 2 => 2};
assert!(!map3.is_proper_submap(map4));

pub fn get_mut<BK>(&mut self, key: &BK) -> Option<&mut V>where BK: Ord + ?Sized, K: Borrow<BK>,

Get a mutable reference to the value for a key from a map.

Time: O(log n)

Examples
let mut map = ordmap!{123 => "lol"};
if let Some(value) = map.get_mut(&123) {
    *value = "omg";
}
assert_eq!(
  map.get(&123),
  Some(&"omg")
);

pub fn get_prev_mut<BK>(&mut self, key: &BK) -> Option<(&K, &mut V)>where BK: Ord + ?Sized, K: Borrow<BK>,

Get the closest smaller entry in a map to a given key as a mutable reference.

If the map contains the given key, this is returned. Otherwise, the closest key in the map smaller than the given value is returned. If the smallest key in the map is larger than the given key, None is returned.

Examples
let mut map = ordmap![1 => 1, 3 => 3, 5 => 5];
if let Some((key, value)) = map.get_prev_mut(&4) {
    *value = 4;
}
assert_eq!(ordmap![1 => 1, 3 => 4, 5 => 5], map);

pub fn get_next_mut<BK>(&mut self, key: &BK) -> Option<(&K, &mut V)>where BK: Ord + ?Sized, K: Borrow<BK>,

Get the closest larger entry in a map to a given key as a mutable reference.

If the set contains the given value, this is returned. Otherwise, the closest value in the set larger than the given value is returned. If the largest value in the set is smaller than the given value, None is returned.

Examples
let mut map = ordmap![1 => 1, 3 => 3, 5 => 5];
if let Some((key, value)) = map.get_next_mut(&4) {
    *value = 4;
}
assert_eq!(ordmap![1 => 1, 3 => 3, 5 => 4], map);

pub fn insert(&mut self, key: K, value: V) -> Option<V>

Insert a key/value mapping into a map.

This is a copy-on-write operation, so that the parts of the map’s structure which are shared with other maps will be safely copied before mutating.

If the map already has a mapping for the given key, the previous value is overwritten.

Time: O(log n)

Examples
let mut map = ordmap!{};
map.insert(123, "123");
map.insert(456, "456");
assert_eq!(
  map,
  ordmap!{123 => "123", 456 => "456"}
);

pub fn remove<BK>(&mut self, k: &BK) -> Option<V>where BK: Ord + ?Sized, K: Borrow<BK>,

Remove a key/value mapping from a map if it exists.

Time: O(log n)

Examples
let mut map = ordmap!{123 => "123", 456 => "456"};
map.remove(&123);
map.remove(&456);
assert!(map.is_empty());

pub fn remove_with_key<BK>(&mut self, k: &BK) -> Option<(K, V)>where BK: Ord + ?Sized, K: Borrow<BK>,

Remove a key/value pair from a map, if it exists, and return the removed key and value.

Time: O(log n)

pub fn update(&self, key: K, value: V) -> OrdMap<K, V>

Construct a new map by inserting a key/value mapping into a map.

If the map already has a mapping for the given key, the previous value is overwritten.

Time: O(log n)

Examples
let map = ordmap!{};
assert_eq!(
  map.update(123, "123"),
  ordmap!{123 => "123"}
);

pub fn alter<F>(&self, f: F, k: K) -> OrdMap<K, V>where F: FnOnce(Option<V>) -> Option<V>,

Update the value for a given key by calling a function with the current value and overwriting it with the function’s return value.

The function gets an Option<V> and returns the same, so that it can decide to delete a mapping instead of updating the value, and decide what to do if the key isn’t in the map.

Time: O(log n)

pub fn without<BK>(&self, k: &BK) -> OrdMap<K, V>where BK: Ord + ?Sized, K: Borrow<BK>,

Remove a key/value pair from a map, if it exists.

Time: O(log n)

pub fn extract<BK>(&self, k: &BK) -> Option<(V, OrdMap<K, V>)>where BK: Ord + ?Sized, K: Borrow<BK>,

Remove a key/value pair from a map, if it exists, and return the removed value as well as the updated list.

Time: O(log n)

pub fn extract_with_key<BK>(&self, k: &BK) -> Option<(K, V, OrdMap<K, V>)>where BK: Ord + ?Sized, K: Borrow<BK>,

Remove a key/value pair from a map, if it exists, and return the removed key and value as well as the updated list.

Time: O(log n)

pub fn split<BK>(&self, split: &BK) -> (OrdMap<K, V>, OrdMap<K, V>)where BK: Ord + ?Sized, K: Borrow<BK>,

Split a map into two, with the left hand map containing keys which are smaller than split, and the right hand map containing keys which are larger than split.

The split mapping is discarded.

pub fn split_lookup<BK>( &self, split: &BK ) -> (OrdMap<K, V>, Option<V>, OrdMap<K, V>)where BK: Ord + ?Sized, K: Borrow<BK>,

Split a map into two, with the left hand map containing keys which are smaller than split, and the right hand map containing keys which are larger than split.

Returns both the two maps and the value of split.

pub fn take(&self, n: usize) -> OrdMap<K, V>

Construct a map with only the n smallest keys from a given map.

pub fn skip(&self, n: usize) -> OrdMap<K, V>

Construct a map with the n smallest keys removed from a given map.

pub fn without_min(&self) -> (Option<V>, OrdMap<K, V>)

Remove the smallest key from a map, and return its value as well as the updated map.

pub fn without_min_with_key(&self) -> (Option<(K, V)>, OrdMap<K, V>)

Remove the smallest key from a map, and return that key, its value as well as the updated map.

pub fn without_max(&self) -> (Option<V>, OrdMap<K, V>)

Remove the largest key from a map, and return its value as well as the updated map.

pub fn without_max_with_key(&self) -> (Option<(K, V)>, OrdMap<K, V>)

Remove the largest key from a map, and return that key, its value as well as the updated map.

pub fn entry(&mut self, key: K) -> Entry<'_, K, V>

Get the Entry for a key in the map for in-place manipulation.

Time: O(log n)

Trait Implementations§

source§

impl<T: FootprintDomain + PartialEq> AbstractDomain for AccessPathTrie<T>

source§

fn join(&mut self, other: &Self) -> JoinResult

source§

impl<T: FootprintDomain> AccessPathMap<T> for AccessPathTrie<T>

source§

impl<T: Clone + FootprintDomain> Clone for AccessPathTrie<T>

source§

fn clone(&self) -> AccessPathTrie<T>

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl<T: Debug + FootprintDomain> Debug for AccessPathTrie<T>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<T: FootprintDomain> Default for AccessPathTrie<T>

source§

fn default() -> Self

Returns the “default value” for a type. Read more
source§

impl<T: FootprintDomain> Deref for AccessPathTrie<T>

§

type Target = MapDomain<Root, TrieNode<T>>

The resulting type after dereferencing.
source§

fn deref(&self) -> &Self::Target

Dereferences the value.
source§

impl<T: FootprintDomain> DerefMut for AccessPathTrie<T>

source§

fn deref_mut(&mut self) -> &mut Self::Target

Mutably dereferences the value.
source§

impl<T: PartialEq + FootprintDomain> PartialEq<AccessPathTrie<T>> for AccessPathTrie<T>

source§

fn eq(&self, other: &AccessPathTrie<T>) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<T: PartialOrd + FootprintDomain> PartialOrd<AccessPathTrie<T>> for AccessPathTrie<T>

source§

fn partial_cmp(&self, other: &AccessPathTrie<T>) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · source§

fn lt(&self, other: &Rhs) -> bool

This method tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · source§

fn le(&self, other: &Rhs) -> bool

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · source§

fn gt(&self, other: &Rhs) -> bool

This method tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · source§

fn ge(&self, other: &Rhs) -> bool

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more
source§

impl<T: Eq + FootprintDomain> Eq for AccessPathTrie<T>

source§

impl<T: FootprintDomain> StructuralEq for AccessPathTrie<T>

source§

impl<T: FootprintDomain> StructuralPartialEq for AccessPathTrie<T>

Auto Trait Implementations§

§

impl<T> RefUnwindSafe for AccessPathTrie<T>where T: RefUnwindSafe,

§

impl<T> Send for AccessPathTrie<T>where T: Send + Sync,

§

impl<T> Sync for AccessPathTrie<T>where T: Send + Sync,

§

impl<T> Unpin for AccessPathTrie<T>where T: Unpin,

§

impl<T> UnwindSafe for AccessPathTrie<T>where T: UnwindSafe + RefUnwindSafe,

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<Q, K> Equivalent<K> for Qwhere Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

const: unstable · source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> Same<T> for T

§

type Output = T

Should always be Self
source§

impl<T> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
const: unstable · source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for Twhere V: MultiLane<T>,

§

fn vzip(self) -> V