pub struct MultikeyBTreeMap<K1, K2, V> {
    main: BTreeMap<K1, (K2, V)>,
    alt: BTreeMap<K2, K1>,
}Expand description
A BTreeMap that supports 2 types of keys per value. All the usual restrictions and warnings for
std::collections::BTreeMap also apply to this struct. Additionally, there is a 1:1
relationship between the 2 key types. In other words, for each K1 in the map, there is exactly
one K2 in the map and vice versa.
Fields§
§main: BTreeMap<K1, (K2, V)>§alt: BTreeMap<K2, K1>Implementations§
source§impl<K1, K2, V> MultikeyBTreeMap<K1, K2, V>
 
impl<K1, K2, V> MultikeyBTreeMap<K1, K2, V>
sourcepub fn get<Q>(&self, key: &Q) -> Option<&V>
 
pub fn get<Q>(&self, key: &Q) -> Option<&V>
Returns a reference to the value corresponding to the key.
The key may be any borrowed form of K1``, but the ordering on the borrowed form must match the ordering on K1`.
sourcepub fn get_alt<Q2>(&self, key: &Q2) -> Option<&V>
 
pub fn get_alt<Q2>(&self, key: &Q2) -> Option<&V>
Returns a reference to the value corresponding to the alternate key.
The key may be any borrowed form of the K2``, but the ordering on the borrowed form must match the ordering on K2`.
Note that this method performs 2 lookups: one to get the main key and another to get the
value associated with that key. For best performance callers should prefer the get method
over this method whenever possible as get only needs to perform one lookup.
sourcepub fn insert(&mut self, k1: K1, k2: K2, v: V) -> Option<V>
 
pub fn insert(&mut self, k1: K1, k2: K2, v: V) -> Option<V>
Inserts a new entry into the map with the given keys and value.
Returns None if the map did not have an entry with k1 or k2 present. If exactly one
key was present, then the value associated with that key is updated, the other key is
removed, and the old value is returned. If both keys were present then the value
associated with the main key is updated, the value associated with the alternate key is
removed, and the old value associated with the main key is returned.
Trait Implementations§
Auto Trait Implementations§
impl<K1, K2, V> Freeze for MultikeyBTreeMap<K1, K2, V>
impl<K1, K2, V> RefUnwindSafe for MultikeyBTreeMap<K1, K2, V>
impl<K1, K2, V> Send for MultikeyBTreeMap<K1, K2, V>
impl<K1, K2, V> Sync for MultikeyBTreeMap<K1, K2, V>
impl<K1, K2, V> Unpin for MultikeyBTreeMap<K1, K2, V>
impl<K1, K2, V> UnwindSafe for MultikeyBTreeMap<K1, K2, V>
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
    T: ?Sized,
 
impl<T> BorrowMut<T> for Twhere
    T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
 
fn borrow_mut(&mut self) -> &mut T
§impl<T> Downcast for Twhere
    T: Any,
 
impl<T> Downcast for Twhere
    T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
 
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
 
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.§fn as_any(&self) -> &(dyn Any + 'static)
 
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
 
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.