[−][src]Struct pour::IdMap
An immutable, optionally hash-consed pointer-sized map from small integer keys to arbitrary data
Implementations
impl<K: RadixKey, V: Clone> IdMap<K, V>
[src]
pub const EMPTY: IdMap<K, V>
[src]
A constant representing an empty map
pub fn new() -> IdMap<K, V>
[src]
Create a new, empty map
Example
let empty = IdMap::<u64, u64>::new(); assert!(empty.is_empty()); assert_eq!(empty.len(), 0); assert_eq!(empty, IdMap::new());
pub fn clear(&mut self) -> Option<Arc<InnerMap<K, V>>>
[src]
Clear this map, returning it's InnerMap
if it was nonempty
pub fn singleton_in<C: ConsCtx<K, V>>(
key: K,
value: V,
ctx: &mut C
) -> IdMap<K, V>
[src]
key: K,
value: V,
ctx: &mut C
) -> IdMap<K, V>
Create a new mapping containing a single element in a given context
Example
let mut ctx1 = MapCtx::<u64, u64>::default(); let mut ctx2 = MapCtx::<u64, u64>::default(); let x = IdMap::singleton_in(5, 7, &mut ctx1); let y = IdMap::singleton_in(5, 7, &mut ctx2); let z = IdMap::singleton_in(5, 7, &mut ctx1); assert_eq!(x, y); assert_eq!(x, z); assert_ne!(x.as_ptr(), y.as_ptr()); assert_eq!(x.as_ptr(), z.as_ptr());
pub fn as_ptr(&self) -> *const InnerMap<K, V>
[src]
Get the pointer underlying this map
This pointer is guaranteed to be null if and only if the map is empty
Example
let mut x = IdMap::new(); assert_eq!(x.as_ptr(), std::ptr::null()); x.try_insert(3, 5); assert_ne!(x.as_ptr(), std::ptr::null()); let mut y = IdMap::singleton(3, 5); assert_ne!(y.as_ptr(), std::ptr::null()); assert_ne!(x.as_ptr(), y.as_ptr()); assert_eq!(x, y);
pub fn ptr_eq(&self, other: &Self) -> bool
[src]
Check whether two IdMap
s are pointer-equal, i.e. point to the same data
pub fn singleton(key: K, value: V) -> IdMap<K, V>
[src]
Create a new mapping containing a single element
Example
let x = IdMap::singleton(3, "Hello"); assert_eq!(x.len(), 1); assert_eq!(x.get(&3), Some(&"Hello")); assert_eq!(x.get(&2), None);
pub fn is_empty(&self) -> bool
[src]
Check whether this map is empty
Example
let mut x = IdMap::new(); assert!(x.is_empty()); x.try_insert(5, 33); assert!(!x.is_empty()); x.remove(&5); assert!(x.is_empty());
pub fn len(&self) -> usize
[src]
Get the number of entries in this map
Example
let mut x = IdMap::new(); assert_eq!(x.len(), 0); x.try_insert(7, 3); assert_eq!(x.len(), 1); x.try_insert(3, 2); assert_eq!(x.len(), 2); x.try_insert(2, 1); assert_eq!(x.len(), 3); x.remove(&2); assert_eq!(x.len(), 2);
pub fn iter(&self) -> IdMapIter<'_, K, V>ⓘ
[src]
Iterate over the entries in this map
Example
let mut x = IdMap::new(); x.try_insert(5, "what"); x.try_insert(3, "buy"); x.try_insert(7, "sell"); let mut v: Vec<_> = x.iter().collect(); v.sort_unstable(); assert_eq!(&v[..], &[ (&3, &"buy"), (&5, &"what"), (&7, &"sell"), ])
pub fn mutate_in<B, M, R, C>(
&self,
key: B,
action: M,
ctx: &mut C
) -> (Option<IdMap<K, V>>, R) where
B: Borrow<K>,
M: FnOnce(B, Option<&V>) -> (Mutation<K, V>, R),
C: ConsCtx<K, V>,
[src]
&self,
key: B,
action: M,
ctx: &mut C
) -> (Option<IdMap<K, V>>, R) where
B: Borrow<K>,
M: FnOnce(B, Option<&V>) -> (Mutation<K, V>, R),
C: ConsCtx<K, V>,
Lookup and mutate an entry of an IdMap
in a given context. Return a new map if any changes were made.
If it exists, the value is passed to the callback. If not, None
is passed in it's place.
The mutation returned from the callback is returned, along with the other result.
pub fn mutate<B, M, R>(&self, key: B, action: M) -> (Option<IdMap<K, V>>, R) where
B: Borrow<K>,
M: FnOnce(B, Option<&V>) -> (Mutation<K, V>, R),
[src]
B: Borrow<K>,
M: FnOnce(B, Option<&V>) -> (Mutation<K, V>, R),
Lookup and mutate an entry of an IdMap
. Return a new map if any changes were made.
If it exists, the value is passed to the callback. If not, None
is passed in it's place.
The mutation returned from the callback is returned, along with the other result.
pub fn removed_in<C: ConsCtx<K, V>>(
&self,
key: &K,
ctx: &mut C
) -> Option<IdMap<K, V>>
[src]
&self,
key: &K,
ctx: &mut C
) -> Option<IdMap<K, V>>
Remove an entry from an IdMap
in a given context: return a new map if any changes were made
Example
let x = IdMap::singleton(3, 5); assert_eq!(x.removed_in(&3, &mut ()), Some(IdMap::new())); assert_eq!(x.removed_in(&5, &mut ()), None);
pub fn removed(&self, key: &K) -> Option<IdMap<K, V>>
[src]
Remove an entry from an IdMap
: return a new map if any changes were made
Example
let x = IdMap::singleton(3, 5); assert_eq!(x.removed(&3), Some(IdMap::new())); assert_eq!(x.removed(&5), None);
pub fn remove_in<C: ConsCtx<K, V>>(&mut self, key: &K, ctx: &mut C) -> bool
[src]
Remove an entry from an IdMap
in a given context, keeping the old value if one was already there.
Return whether any changes were made
Example
let mut x = IdMap::singleton(3, 5); let y = x.clone(); assert!(!x.remove_in(&5, &mut ())); assert_eq!(x, y); assert!(x.remove_in(&3, &mut ())); assert_eq!(x, IdMap::new());
pub fn remove(&mut self, key: &K) -> bool
[src]
Remove an entry from an IdMap
, keeping the old value if one was already there.
Return whether any changes were made
Example
let mut x = IdMap::singleton(3, 5); let y = x.clone(); assert!(!x.remove(&5)); assert_eq!(x, y); assert!(x.remove(&3)); assert_eq!(x, IdMap::new());
pub fn inserted_in<C: ConsCtx<K, V>>(
&self,
key: K,
value: V,
ctx: &mut C
) -> Option<IdMap<K, V>>
[src]
&self,
key: K,
value: V,
ctx: &mut C
) -> Option<IdMap<K, V>>
Insert an entry into an IdMap
in a given context, replacing the old value if one was already there.
Return a new map if any changes were made
Example
let x = IdMap::singleton(3, 2); assert_eq!( x.inserted_in(3, 5, &mut ()), Some(IdMap::singleton(3, 5)) ); let y = x.inserted_in(4, 5, &mut ()).unwrap(); assert_ne!(x, y); assert_eq!(x.get(&3), Some(&2)); assert_eq!(x.get(&4), None); assert_eq!(y.get(&3), Some(&2)); assert_eq!(y.get(&4), Some(&5));
pub fn inserted(&self, key: K, value: V) -> Option<IdMap<K, V>>
[src]
Insert an entry into an IdMap
, replacing the old value if one was already there.
Return a new map if any changes were made
Example
let x = IdMap::singleton(3, 2); assert_eq!( x.inserted(3, 5), Some(IdMap::singleton(3, 5)) ); let y = x.inserted(4, 5).unwrap(); assert_ne!(x, y); assert_eq!(x.get(&3), Some(&2)); assert_eq!(x.get(&4), None); assert_eq!(y.get(&3), Some(&2)); assert_eq!(y.get(&4), Some(&5));
pub fn insert_in<C: ConsCtx<K, V>>(
&mut self,
key: K,
value: V,
ctx: &mut C
) -> bool
[src]
&mut self,
key: K,
value: V,
ctx: &mut C
) -> bool
Insert an entry into an IdMap
in a given context, replacing the old value if one was already there.
Return whether any changes were made
Example
let mut x = IdMap::new(); assert!(x.insert_in(3, 2, &mut ())); assert_eq!(x.get(&3), Some(&2)); assert!(x.insert_in(3, 5, &mut ())); assert_eq!(x.get(&3), Some(&5));
pub fn insert(&mut self, key: K, value: V) -> bool
[src]
Insert an entry into an IdMap
, replacing the old value if one was already there.
Return whether any changes were made
Example
let mut x = IdMap::new(); assert!(x.insert(3, 2)); assert_eq!(x.get(&3), Some(&2)); assert!(x.insert(3, 5)); assert_eq!(x.get(&3), Some(&5));
pub fn try_inserted_in<C: ConsCtx<K, V>>(
&self,
key: K,
value: V,
ctx: &mut C
) -> Option<IdMap<K, V>>
[src]
&self,
key: K,
value: V,
ctx: &mut C
) -> Option<IdMap<K, V>>
Insert an entry into an IdMap
in a given context, keeping the old value if one was already there.
Return a new map if any changes were made
Example
let x = IdMap::singleton(3, 2); assert_eq!(x.try_inserted_in(3, 5, &mut ()), None); let y = x.try_inserted_in(4, 5, &mut ()).unwrap(); assert_ne!(x, y); assert_eq!(x.get(&3), Some(&2)); assert_eq!(x.get(&4), None); assert_eq!(y.get(&3), Some(&2)); assert_eq!(y.get(&4), Some(&5));
pub fn try_inserted(&self, key: K, value: V) -> Option<IdMap<K, V>>
[src]
Insert an entry into an IdMap
, keeping the old value if one was already there.
Return a new map if any changes were made
Example
let x = IdMap::singleton(3, 2); assert_eq!(x.try_inserted(3, 5), None); let y = x.try_inserted(4, 5).unwrap(); assert_ne!(x, y); assert_eq!(x.get(&3), Some(&2)); assert_eq!(x.get(&4), None); assert_eq!(y.get(&3), Some(&2)); assert_eq!(y.get(&4), Some(&5));
pub fn try_insert_in<C: ConsCtx<K, V>>(
&mut self,
key: K,
value: V,
ctx: &mut C
) -> bool
[src]
&mut self,
key: K,
value: V,
ctx: &mut C
) -> bool
Insert an entry into an IdMap
in a given context, keeping the old value if one was already there.
Return whether any changes were made
Example
let mut x = IdMap::new(); assert!(x.try_insert_in(3, 2, &mut ())); assert_eq!(x.get(&3), Some(&2)); assert!(!x.try_insert_in(3, 5, &mut ())); assert_eq!(x.get(&3), Some(&2));
pub fn try_insert(&mut self, key: K, value: V) -> bool
[src]
Insert an entry into an IdMap
, keeping the old value if one was already there.
Return whether any changes were made
Example
let mut x = IdMap::new(); assert!(x.try_insert(3, 2)); assert_eq!(x.get(&3), Some(&2)); assert!(!x.try_insert(3, 5)); assert_eq!(x.get(&3), Some(&2));
pub fn get(&self, key: &K) -> Option<&V>
[src]
Lookup an entry of an IdMap
, returning the value associated with it, if any
Example
let mut x = IdMap::singleton(3, 5); assert_eq!(x.get(&3), Some(&5)); assert_eq!(x.get(&2), None); x.try_insert(2, 4); assert_eq!(x.get(&2), Some(&4)); x.insert_conservative(2, 2); assert_eq!(x.get(&2), Some(&2));
pub fn contains(&self, key: &K) -> bool
[src]
Lookup whether an item is contained in an IdMap
.
Example
let x = IdMap::singleton(7, 3); assert!(x.contains(&7)); assert!(!x.contains(&3));
pub fn mutated_vals_in<M, C>(
&self,
mutator: &mut M,
ctx: &mut C
) -> Option<IdMap<K, V>> where
M: UnaryMutator<K, V>,
C: ConsCtx<K, V>,
[src]
&self,
mutator: &mut M,
ctx: &mut C
) -> Option<IdMap<K, V>> where
M: UnaryMutator<K, V>,
C: ConsCtx<K, V>,
Mutate the values of a map in a given context. Return Some
if something changed.
Example
let x = IdMap::singleton(3, 5); let mut mutator = FilterMap::new( |key, value| if key == value { None } else { Some(key * value) } ); let y = x.mutated_vals_in(&mut mutator, &mut ()); assert_eq!(y, Some(IdMap::singleton(3, 15)));
pub fn mutated_vals<M>(&self, mutator: &mut M) -> Option<IdMap<K, V>> where
M: UnaryMutator<K, V>,
[src]
M: UnaryMutator<K, V>,
Mutate the values of a map. Return Some
if something changed.
pub fn mutate_vals_in<M, C>(&mut self, mutator: &mut M, ctx: &mut C) -> bool where
M: UnaryMutator<K, V>,
C: ConsCtx<K, V>,
[src]
M: UnaryMutator<K, V>,
C: ConsCtx<K, V>,
Mutate the values of a map. Return if something changed.
pub fn mutate_vals<M>(&mut self, mutator: &mut M) -> bool where
M: UnaryMutator<K, V>,
[src]
M: UnaryMutator<K, V>,
Mutate the values of a map. Return if something changed.
Examples
let mut x = IdMap::new(); for i in 0..100 { x.try_insert(i, 3); } let mut y = x.clone(); assert!(!y.mutate_vals(&mut NullMutator)); assert_eq!(x.as_ptr(), y.as_ptr()); let mut mutator = FilterMap::new( |key, value| if *key < 30 { None } else { Some(*key * *value) } ); assert!(y.mutate_vals(&mut mutator)); assert_ne!(x, y); assert_eq!(y.len(), 70); assert_eq!(x.get(&4), Some(&3)); assert_eq!(y.get(&4), None); assert_eq!(x.get(&40), Some(&3)); assert_eq!(y.get(&40), Some(&120)); assert!(x.mutate_vals(&mut mutator)); assert_ne!(x.as_ptr(), y.as_ptr()); assert_eq!(x, y); assert!(y.mutate_vals(&mut DeleteMutator)); assert!(y.is_empty());
pub fn join_mutate_in<IM, LM, RM, C>(
&self,
other: &Self,
intersection_mutator: &mut IM,
left_mutator: &mut LM,
right_mutator: &mut RM,
ctx: &mut C
) -> BinaryResult<IdMap<K, V>> where
IM: BinaryMutator<K, V>,
LM: UnaryMutator<K, V>,
RM: UnaryMutator<K, V>,
C: ConsCtx<K, V>,
[src]
&self,
other: &Self,
intersection_mutator: &mut IM,
left_mutator: &mut LM,
right_mutator: &mut RM,
ctx: &mut C
) -> BinaryResult<IdMap<K, V>> where
IM: BinaryMutator<K, V>,
LM: UnaryMutator<K, V>,
RM: UnaryMutator<K, V>,
C: ConsCtx<K, V>,
Join-mutate two maps by applying a binary mutator to their key intersection and unary
mutators to their left and right intersection. If cons
is true, the maps are assumed to
be consistently hash-consed (i.e. an InnerMap
in one map is rec_eq
to one in another map
if and only if they are pointer-equal, i.e. compare equal with ==
), which can provide
additional speedup. Return Some
if something changed.
pub fn left_union_in<C: ConsCtx<K, V>>(
&self,
other: &IdMap<K, V>,
ctx: &mut C
) -> BinaryResult<IdMap<K, V>>
[src]
&self,
other: &IdMap<K, V>,
ctx: &mut C
) -> BinaryResult<IdMap<K, V>>
Take the union of two maps: if any keys are shared between two maps, always take the left value
pub fn left_intersect_in<C: ConsCtx<K, V>>(
&self,
other: &IdMap<K, V>,
ctx: &mut C
) -> BinaryResult<IdMap<K, V>>
[src]
&self,
other: &IdMap<K, V>,
ctx: &mut C
) -> BinaryResult<IdMap<K, V>>
Take the intersection of two maps, taking the left value in case of conflict
pub fn left_union(&self, other: &IdMap<K, V>) -> BinaryResult<IdMap<K, V>>
[src]
Take the union of two maps: if any keys are shared between two maps, always take the left value
pub fn left_intersect(&self, other: &IdMap<K, V>) -> BinaryResult<IdMap<K, V>>
[src]
Take the intersection of two maps, taking the left value in case of conflict
pub fn right_union_in<C: ConsCtx<K, V>>(
&self,
other: &IdMap<K, V>,
ctx: &mut C
) -> BinaryResult<IdMap<K, V>>
[src]
&self,
other: &IdMap<K, V>,
ctx: &mut C
) -> BinaryResult<IdMap<K, V>>
Take the union of two maps: if any keys are shared between two maps, always take the right value
pub fn right_intersect_in<C: ConsCtx<K, V>>(
&self,
other: &IdMap<K, V>,
ctx: &mut C
) -> BinaryResult<IdMap<K, V>>
[src]
&self,
other: &IdMap<K, V>,
ctx: &mut C
) -> BinaryResult<IdMap<K, V>>
Take the intersection of two maps, taking the right value in case of conflict
pub fn right_union(&self, other: &IdMap<K, V>) -> BinaryResult<IdMap<K, V>>
[src]
Take the union of two maps: if any keys are shared between two maps, always take the right value
pub fn right_intersect(&self, other: &IdMap<K, V>) -> BinaryResult<IdMap<K, V>>
[src]
Take the intersection of two maps, taking the left value in case of conflict
pub fn union_in<C: ConsCtx<K, V>>(
&self,
other: &IdMap<K, V>,
ctx: &mut C
) -> BinaryResult<IdMap<K, V>>
[src]
&self,
other: &IdMap<K, V>,
ctx: &mut C
) -> BinaryResult<IdMap<K, V>>
Take the union of two maps: if any keys are shared between two maps, it is unspecified which of the two values is in the result
pub fn intersect_in<C: ConsCtx<K, V>>(
&self,
other: &IdMap<K, V>,
ctx: &mut C
) -> BinaryResult<IdMap<K, V>>
[src]
&self,
other: &IdMap<K, V>,
ctx: &mut C
) -> BinaryResult<IdMap<K, V>>
Take the intersection of two maps, taking an unspecified value in case of conflict
pub fn sym_diff_in<C: ConsCtx<K, V>>(
&self,
other: &IdMap<K, V>,
ctx: &mut C
) -> BinaryResult<IdMap<K, V>>
[src]
&self,
other: &IdMap<K, V>,
ctx: &mut C
) -> BinaryResult<IdMap<K, V>>
Take the symmetric difference of two maps
pub fn left_complement_in<C: ConsCtx<K, V>>(
&self,
other: &IdMap<K, V>,
ctx: &mut C
) -> BinaryResult<IdMap<K, V>>
[src]
&self,
other: &IdMap<K, V>,
ctx: &mut C
) -> BinaryResult<IdMap<K, V>>
Take the complement of this map's entries with respect to another's keys
pub fn right_complement_in<C: ConsCtx<K, V>>(
&self,
other: &IdMap<K, V>,
ctx: &mut C
) -> BinaryResult<IdMap<K, V>>
[src]
&self,
other: &IdMap<K, V>,
ctx: &mut C
) -> BinaryResult<IdMap<K, V>>
Take the complement of this map's keys with respect to another's entries
pub fn complement_in<C: ConsCtx<K, V>>(
&self,
other: &IdMap<K, V>,
ctx: &mut C
) -> BinaryResult<IdMap<K, V>>
[src]
&self,
other: &IdMap<K, V>,
ctx: &mut C
) -> BinaryResult<IdMap<K, V>>
Take the complement of this map' with another, arbitrarily returning this map's or the other's values on the intersection!
pub fn union(&self, other: &IdMap<K, V>) -> BinaryResult<IdMap<K, V>>
[src]
Take the union of two maps: if any keys are shared between two maps, it is unspecified which of the two values is in the result
pub fn intersect(&self, other: &IdMap<K, V>) -> BinaryResult<IdMap<K, V>>
[src]
Take the intersection of two maps, taking an unspecified value in case of conflict
pub fn sym_diff(&self, other: &IdMap<K, V>) -> BinaryResult<IdMap<K, V>>
[src]
Take the symmetric difference of two maps
pub fn left_complement(&self, other: &IdMap<K, V>) -> BinaryResult<IdMap<K, V>>
[src]
Take the complement of this map's entries with respect to another's keys
pub fn right_complement(&self, other: &IdMap<K, V>) -> BinaryResult<IdMap<K, V>>
[src]
Take the complement of this map's keys with respect to another's entries
pub fn complement(&self, other: &IdMap<K, V>) -> BinaryResult<IdMap<K, V>>
[src]
Take the complement of this map' with another, arbitrarily returning this map's or the other's values on the intersection!
pub fn left_unioned_in<C: ConsCtx<K, V>>(
&self,
other: &IdMap<K, V>,
ctx: &mut C
) -> IdMap<K, V>
[src]
&self,
other: &IdMap<K, V>,
ctx: &mut C
) -> IdMap<K, V>
Take the union of two maps: if any keys are shared between two maps, always take the left value
pub fn left_intersected_in<C: ConsCtx<K, V>>(
&self,
other: &IdMap<K, V>,
ctx: &mut C
) -> IdMap<K, V>
[src]
&self,
other: &IdMap<K, V>,
ctx: &mut C
) -> IdMap<K, V>
Take the intersection of two maps, taking the left value in case of conflict
pub fn left_unioned(&self, other: &IdMap<K, V>) -> IdMap<K, V>
[src]
Take the union of two maps: if any keys are shared between two maps, always take the left value
pub fn left_intersected(&self, other: &IdMap<K, V>) -> IdMap<K, V>
[src]
Take the intersection of two maps, taking the left value in case of conflict
pub fn right_unioned_in<C: ConsCtx<K, V>>(
&self,
other: &IdMap<K, V>,
ctx: &mut C
) -> IdMap<K, V>
[src]
&self,
other: &IdMap<K, V>,
ctx: &mut C
) -> IdMap<K, V>
Take the union of two maps: if any keys are shared between two maps, always take the left value
pub fn right_intersected_in<C: ConsCtx<K, V>>(
&self,
other: &IdMap<K, V>,
ctx: &mut C
) -> IdMap<K, V>
[src]
&self,
other: &IdMap<K, V>,
ctx: &mut C
) -> IdMap<K, V>
Take the intersection of two maps, taking the left value in case of conflict
pub fn right_unioned(&self, other: &IdMap<K, V>) -> IdMap<K, V>
[src]
Take the union of two maps: if any keys are shared between two maps, always take the left value
pub fn right_intersected(&self, other: &IdMap<K, V>) -> IdMap<K, V>
[src]
Take the intersection of two maps, taking the left value in case of conflict
pub fn unioned_in<C: ConsCtx<K, V>>(
&self,
other: &IdMap<K, V>,
ctx: &mut C
) -> IdMap<K, V>
[src]
&self,
other: &IdMap<K, V>,
ctx: &mut C
) -> IdMap<K, V>
Take the union of two maps: if any keys are shared between two maps, it is unspecified which of the two values is in the result
pub fn intersected_in<C: ConsCtx<K, V>>(
&self,
other: &IdMap<K, V>,
ctx: &mut C
) -> IdMap<K, V>
[src]
&self,
other: &IdMap<K, V>,
ctx: &mut C
) -> IdMap<K, V>
Take the intersection of two maps, taking an unspecified value in case of conflict
pub fn sym_diffed_in<C: ConsCtx<K, V>>(
&self,
other: &IdMap<K, V>,
ctx: &mut C
) -> IdMap<K, V>
[src]
&self,
other: &IdMap<K, V>,
ctx: &mut C
) -> IdMap<K, V>
Take the symmetric difference of two maps
pub fn left_complemented_in<C: ConsCtx<K, V>>(
&self,
other: &IdMap<K, V>,
ctx: &mut C
) -> IdMap<K, V>
[src]
&self,
other: &IdMap<K, V>,
ctx: &mut C
) -> IdMap<K, V>
Take the symmetric difference of two maps
pub fn right_complemented_in<C: ConsCtx<K, V>>(
&self,
other: &IdMap<K, V>,
ctx: &mut C
) -> IdMap<K, V>
[src]
&self,
other: &IdMap<K, V>,
ctx: &mut C
) -> IdMap<K, V>
Take the symmetric difference of two maps
pub fn complemented_in<C: ConsCtx<K, V>>(
&self,
other: &IdMap<K, V>,
ctx: &mut C
) -> IdMap<K, V>
[src]
&self,
other: &IdMap<K, V>,
ctx: &mut C
) -> IdMap<K, V>
Take the symmetric difference of two maps
pub fn unioned(&self, other: &IdMap<K, V>) -> IdMap<K, V>
[src]
Take the union of two maps: if any keys are shared between two maps, it is unspecified which of the two values is in the result
pub fn intersected(&self, other: &IdMap<K, V>) -> IdMap<K, V>
[src]
Take the intersection of two maps, taking an unspecified value in case of conflict
pub fn sym_diffed(&self, other: &IdMap<K, V>) -> IdMap<K, V>
[src]
Take the symmetric difference of two maps
pub fn left_complemented(&self, other: &IdMap<K, V>) -> IdMap<K, V>
[src]
Take the complement of this map's entries with respect to another's keys
pub fn complemented(&self, other: &IdMap<K, V>) -> IdMap<K, V>
[src]
Take the complement of this map's entries with respect to another's keys
impl<K: RadixKey, V: Clone + Eq> IdMap<K, V>
[src]
pub fn inserted_conservative_in<C: ConsCtx<K, V>>(
&self,
key: K,
value: V,
ctx: &mut C
) -> Option<IdMap<K, V>>
[src]
&self,
key: K,
value: V,
ctx: &mut C
) -> Option<IdMap<K, V>>
Insert an entry of an IdMap
in a given context, updating the old value if one was already there.
Return a new map if any changes were made
pub fn inserted_conservative(&self, key: K, value: V) -> Option<IdMap<K, V>>
[src]
Insert an entry of an IdMap
, updating the old value if one was already there.
Return a new map if any changes were made
pub fn insert_conservative_in<C: ConsCtx<K, V>>(
&mut self,
key: K,
value: V,
ctx: &mut C
) -> bool
[src]
&mut self,
key: K,
value: V,
ctx: &mut C
) -> bool
Insert an entry into an IdMap
in a given context, updating the old value if one was already there.
Return whether any changes were made
pub fn insert_conservative(&mut self, key: K, value: V) -> bool
[src]
Insert an entry into an IdMap
, updating the old value if one was already there.
Return whether any changes were made
pub fn is_submap(&self, other: &IdMap<K, V>, cons: bool) -> bool
[src]
Check whether this map is a submap of another. A map is considered to be a submap of itself.
If cons
is true, this map is assumed to be hash-consed with the other
pub fn domain_is_subset<U: Clone + Eq>(&self, other: &IdMap<K, U>) -> bool
[src]
Check whether this map's domain is a subset of another's.
pub fn domains_intersect<U: Clone + Eq>(&self, other: &IdMap<K, U>) -> bool
[src]
Check whether this map's domain has a nonempty intersection with another map's
Example
let mut a = IdSet::new(); for i in 0..10 { a.try_insert(i, ()); } let mut b = IdSet::new(); for i in 5..20 { b.try_insert(i, ()); } let mut c = IdMap::new(); for i in 10..20 { c.try_insert(i, 3*i); } assert!(a.domains_intersect(&a)); assert!(b.domains_intersect(&b)); assert!(c.domains_intersect(&c)); assert!(a.domains_intersect(&b)); assert!(b.domains_intersect(&a)); assert!(b.domains_intersect(&c)); assert!(c.domains_intersect(&b)); assert!(!a.domains_intersect(&c)); assert!(!c.domains_intersect(&a));
pub fn domains_disjoint<U: Clone + Eq>(&self, other: &IdMap<K, U>) -> bool
[src]
Check whether two maps have disjoint domains
Example
let mut a = IdSet::new(); for i in 100..1000 { a.try_insert(i, ()); } let mut b = IdMap::new(); for i in 50..2000 { b.try_insert(i, 2*i); } let mut c = IdSet::new(); for i in 1500..2500 { c.try_insert(i, ()); } assert!(!a.domains_disjoint(&a)); assert!(!b.domains_disjoint(&b)); assert!(!c.domains_disjoint(&c)); assert!(!a.domains_disjoint(&b)); assert!(!b.domains_disjoint(&a)); assert!(!b.domains_disjoint(&c)); assert!(!c.domains_disjoint(&b)); assert!(a.domains_disjoint(&c)); assert!(c.domains_disjoint(&a));
pub fn map_cmp(&self, other: &IdMap<K, V>, cons: bool) -> Option<Ordering>
[src]
Partially order maps based off the submap relation
pub fn domain_cmp(&self, other: &IdMap<K, V>) -> Option<Ordering>
[src]
Partially order the domains of maps based off the subset relation
Trait Implementations
impl<K: Clone + RadixKey, V: Clone> Clone for IdMap<K, V>
[src]
impl<K: Debug + RadixKey, V: Debug + Clone> Debug for IdMap<K, V>
[src]
impl<K: RadixKey, V: Clone> Default for IdMap<K, V>
[src]
impl<K: RadixKey, V: Clone + Eq> Eq for IdMap<K, V>
[src]
impl<K: RadixKey, V: Clone> FromIterator<(K, V)> for IdMap<K, V>
[src]
impl<K: RadixKey, V: Clone> IntoIterator for IdMap<K, V>
[src]
type Item = (K, V)
The type of the elements being iterated over.
type IntoIter = IdMapIntoIter<K, V>
Which kind of iterator are we turning this into?
fn into_iter(self) -> IdMapIntoIter<K, V>ⓘNotable traits for IdMapIntoIter<K, V>
impl<K: RadixKey, V: Clone> Iterator for IdMapIntoIter<K, V> type Item = (K, V);
[src]
Notable traits for IdMapIntoIter<K, V>
impl<K: RadixKey, V: Clone> Iterator for IdMapIntoIter<K, V> type Item = (K, V);
impl<K: RadixKey, V: Clone + Eq> PartialEq<IdMap<K, V>> for IdMap<K, V>
[src]
fn eq(&self, other: &IdMap<K, V>) -> bool
[src]
#[must_use]fn ne(&self, other: &Rhs) -> bool
1.0.0[src]
impl<K: RadixKey, V: Eq + Clone> PartialOrd<IdMap<K, V>> for IdMap<K, V>
[src]
Auto Trait Implementations
impl<K, V> RefUnwindSafe for IdMap<K, V> where
K: RefUnwindSafe,
V: RefUnwindSafe,
<K as RadixKey>::DepthType: RefUnwindSafe,
<K as RadixKey>::PatternType: RefUnwindSafe,
K: RefUnwindSafe,
V: RefUnwindSafe,
<K as RadixKey>::DepthType: RefUnwindSafe,
<K as RadixKey>::PatternType: RefUnwindSafe,
impl<K, V> Send for IdMap<K, V> where
K: Send + Sync,
V: Send + Sync,
<K as RadixKey>::DepthType: Send + Sync,
<K as RadixKey>::PatternType: Send + Sync,
K: Send + Sync,
V: Send + Sync,
<K as RadixKey>::DepthType: Send + Sync,
<K as RadixKey>::PatternType: Send + Sync,
impl<K, V> Sync for IdMap<K, V> where
K: Send + Sync,
V: Send + Sync,
<K as RadixKey>::DepthType: Send + Sync,
<K as RadixKey>::PatternType: Send + Sync,
K: Send + Sync,
V: Send + Sync,
<K as RadixKey>::DepthType: Send + Sync,
<K as RadixKey>::PatternType: Send + Sync,
impl<K, V> Unpin for IdMap<K, V> where
K: Unpin,
V: Unpin,
<K as RadixKey>::DepthType: Unpin,
<K as RadixKey>::PatternType: Unpin,
K: Unpin,
V: Unpin,
<K as RadixKey>::DepthType: Unpin,
<K as RadixKey>::PatternType: Unpin,
impl<K, V> UnwindSafe for IdMap<K, V> where
K: RefUnwindSafe + UnwindSafe,
V: RefUnwindSafe + UnwindSafe,
<K as RadixKey>::DepthType: RefUnwindSafe + UnwindSafe,
<K as RadixKey>::PatternType: RefUnwindSafe + UnwindSafe,
K: RefUnwindSafe + UnwindSafe,
V: RefUnwindSafe + UnwindSafe,
<K as RadixKey>::DepthType: RefUnwindSafe + UnwindSafe,
<K as RadixKey>::PatternType: RefUnwindSafe + UnwindSafe,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Erasable for T
pub unsafe fn unerase(this: NonNull<Erased>) -> NonNull<T>
pub const ACK_1_1_0: bool
fn erase(this: NonNull<Self>) -> NonNull<Erased>
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<I> IntoIterator for I where
I: Iterator,
[src]
I: Iterator,
type Item = <I as Iterator>::Item
The type of the elements being iterated over.
type IntoIter = I
Which kind of iterator are we turning this into?
pub fn into_iter(self) -> I
[src]
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,