1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123
use alloc::btree_map::{BTreeMap, Iter, IterMut}; use core::borrow::Borrow; use super::super::*; impl<K, V> Collection for BTreeMap<K, V> where K: Eq + Ord, { #[inline(always)] fn len(&self) -> usize { BTreeMap::<K, V>::len(self) } } impl<K, V> CollectionMut for BTreeMap<K, V> where K: Eq + Ord, { #[inline(always)] fn clear(&mut self) { BTreeMap::<K, V>::clear(self); } } impl<K, V> Create<(K, V)> for BTreeMap<K, V> where K: Eq + Ord, { #[inline(always)] fn create() -> Self { BTreeMap::<K, V>::new() } #[inline(always)] fn create_with_capacity(_: usize) -> Self { BTreeMap::<K, V>::new() } #[inline(always)] fn add_element(&mut self, (key, value): (K, V)) { BTreeMap::<K, V>::insert(self, key, value); } } impl<'a, K, V> InsertMut<K, V> for BTreeMap<K, V> where K: Eq + Ord, { type Output = Option<V>; #[inline] fn insert(&mut self, k: K, v: V) -> Self::Output { BTreeMap::<K, V>::insert(self, k, v) } } impl<'a, K, Q: ?Sized, V> RemoveMut<&'a Q> for BTreeMap<K, V> where K: Eq + Ord + Borrow<Q>, Q: Eq + Ord, { type Output = Option<V>; #[inline] fn remove(&mut self, k: &Q) -> Self::Output { BTreeMap::<K, V>::remove(self, k) } } impl<'a, K, Q: ?Sized, V> Get<&'a Q> for BTreeMap<K, V> where K: Eq + Ord + Borrow<Q>, Q: Eq + Ord, { type Output = V; #[inline(always)] fn get(&self, k: &Q) -> Option<&Self::Output> { BTreeMap::get(self, k) } } impl<'a, K, Q: ?Sized, V> GetMut<&'a Q> for BTreeMap<K, V> where K: Eq + Ord + Borrow<Q>, Q: Eq + Ord, { #[inline(always)] fn get_mut(&mut self, k: &Q) -> Option<&mut Self::Output> { BTreeMap::get_mut(self, k) } } impl<'a, K, V> Iterable<'a, (&'a K, &'a V)> for BTreeMap<K, V> where K: 'a + Eq + Ord, V: 'a, { type Iter = Iter<'a, K, V>; #[inline(always)] fn iter(&'a self) -> Self::Iter { BTreeMap::<K, V>::iter(self) } } impl<'a, K, V> IterableMut<'a, (&'a K, &'a mut V)> for BTreeMap<K, V> where K: 'a + Eq + Ord, V: 'a, { type IterMut = IterMut<'a, K, V>; #[inline(always)] fn iter_mut(&'a mut self) -> Self::IterMut { BTreeMap::<K, V>::iter_mut(self) } } impl<'a, K, Q: ?Sized, V> MapMut<'a, K, Q, V> for BTreeMap<K, V> where K: 'a + Eq + Ord + Borrow<Q>, Q: 'a + Eq + Ord, V: 'a, {} impl<'a, K, Q: ?Sized, V> Map<'a, K, Q, V> for BTreeMap<K, V> where K: 'a + Eq + Ord + Borrow<Q>, Q: 'a + Eq + Ord, V: 'a, { #[inline(always)] fn contains_key(&self, k: &Q) -> bool { BTreeMap::contains_key(self, k) } }