Struct proto_vulcan::state::SMap [−][src]
Expand description
Substitution Map
Substitution maps track the binding of variables to terms.
Implementations
Extend substitution map with a new substitution
Walk substitution map
Walking the substitution map recursively traverses the map until no next term is found, or the term found is a non-variable.
Alternative walk of the substitution map that does not bind the return value lifetime
to lifetime of the input variable k
.
Deeper walk of substitution map
Walks the substitution map recursively like walk()
, but does not stop at lists, and
instead recurses to do the deep walk also for the list elements. Returns a term which
is a tree where all leaves are walked terms.
Check that the variable x
is not contained in the term v
.
Occurs check is used to prevent unification of terms that would cause the variable to be contained in itself.
Reify substitution map
Reification modifies the substitution map such that all variables of the given LTerm have walkable values assigned to them in the substitution map. If the term or any subterm walks into a variable, a reified name is added to the substitution map. The reified name denotes that the the solution solves the logic query with any value of the variable.
This is typically used to generate a reifying substitution map from an empty map. The reifying map maps free variables to reified names. See State::reify().
Check if the given logic term refers to any unassociated variables
Returns a list of variables referenced by the substitution map
Methods from Deref<Target = HashMap<LTerm<U, E>, LTerm<U, E>>>
Returns the number of elements the map can hold without reallocating.
This number is a lower bound; the HashMap<K, V>
might be able to hold
more, but is guaranteed to be able to hold at least this many.
Examples
use std::collections::HashMap;
let map: HashMap<i32, i32> = HashMap::with_capacity(100);
assert!(map.capacity() >= 100);
An iterator visiting all keys in arbitrary order.
The iterator element type is &'a K
.
Examples
use std::collections::HashMap;
let mut map = HashMap::new();
map.insert("a", 1);
map.insert("b", 2);
map.insert("c", 3);
for key in map.keys() {
println!("{}", key);
}
An iterator visiting all values in arbitrary order.
The iterator element type is &'a V
.
Examples
use std::collections::HashMap;
let mut map = HashMap::new();
map.insert("a", 1);
map.insert("b", 2);
map.insert("c", 3);
for val in map.values() {
println!("{}", val);
}
An iterator visiting all key-value pairs in arbitrary order.
The iterator element type is (&'a K, &'a V)
.
Examples
use std::collections::HashMap;
let mut map = HashMap::new();
map.insert("a", 1);
map.insert("b", 2);
map.insert("c", 3);
for (key, val) in map.iter() {
println!("key: {} val: {}", key, val);
}
Returns the number of elements in the map.
Examples
use std::collections::HashMap;
let mut a = HashMap::new();
assert_eq!(a.len(), 0);
a.insert(1, "a");
assert_eq!(a.len(), 1);
Returns true
if the map contains no elements.
Examples
use std::collections::HashMap;
let mut a = HashMap::new();
assert!(a.is_empty());
a.insert(1, "a");
assert!(!a.is_empty());
Returns a reference to the map’s BuildHasher
.
Examples
use std::collections::HashMap;
use std::collections::hash_map::RandomState;
let hasher = RandomState::new();
let map: HashMap<i32, i32> = HashMap::with_hasher(hasher);
let hasher: &RandomState = map.hasher();
Returns a reference to the value corresponding to the key.
The key may be any borrowed form of the map’s key type, but
Hash
and Eq
on the borrowed form must match those for
the key type.
Examples
use std::collections::HashMap;
let mut map = HashMap::new();
map.insert(1, "a");
assert_eq!(map.get(&1), Some(&"a"));
assert_eq!(map.get(&2), None);
Returns the key-value pair corresponding to the supplied key.
The supplied key may be any borrowed form of the map’s key type, but
Hash
and Eq
on the borrowed form must match those for
the key type.
Examples
use std::collections::HashMap;
let mut map = HashMap::new();
map.insert(1, "a");
assert_eq!(map.get_key_value(&1), Some((&1, &"a")));
assert_eq!(map.get_key_value(&2), None);
Returns true
if the map contains a value for the specified key.
The key may be any borrowed form of the map’s key type, but
Hash
and Eq
on the borrowed form must match those for
the key type.
Examples
use std::collections::HashMap;
let mut map = HashMap::new();
map.insert(1, "a");
assert_eq!(map.contains_key(&1), true);
assert_eq!(map.contains_key(&2), false);
🔬 This is a nightly-only experimental API. (hash_raw_entry
)
hash_raw_entry
)Creates a raw immutable entry builder for the HashMap.
Raw entries provide the lowest level of control for searching and manipulating a map. They must be manually initialized with a hash and then manually searched.
This is useful for
- Hash memoization
- Using a search key that doesn’t work with the Borrow trait
- Using custom comparison logic without newtype wrappers
Unless you are in such a situation, higher-level and more foolproof APIs like
get
should be preferred.
Immutable raw entries have very limited use; you might instead want raw_entry_mut
.
Trait Implementations
Auto Trait Implementations
impl<U, E> !RefUnwindSafe for SMap<U, E>
impl<U, E> !UnwindSafe for SMap<U, E>
Blanket Implementations
Mutably borrows from an owned value. Read more