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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
use crate::{
Clear, Collection, CollectionMut, CollectionRef, Get, GetKeyValue, GetMut, Iter, Keyed,
KeyedRef, Len, MapInsert, MapIter, MapIterMut, Remove, SimpleCollectionMut,
SimpleCollectionRef,
};
use std::{borrow::Borrow, collections::BTreeMap};
impl<K, V> Collection for BTreeMap<K, V> {
type Item = V;
}
impl<K, V> CollectionRef for BTreeMap<K, V> {
type ItemRef<'a> = &'a V where Self: 'a;
crate::covariant_item_ref!();
}
impl<K, V> CollectionMut for BTreeMap<K, V> {
type ItemMut<'a> = &'a mut V where Self: 'a;
crate::covariant_item_mut!();
}
impl<K, V> SimpleCollectionRef for BTreeMap<K, V> {
fn into_ref<'a>(r: &'a V) -> &'a V
where
Self: 'a,
{
r
}
}
impl<K, V> SimpleCollectionMut for BTreeMap<K, V> {
fn into_mut<'a>(r: &'a mut V) -> &'a mut V
where
Self: 'a,
{
r
}
}
impl<K, V> Keyed for BTreeMap<K, V> {
type Key = K;
}
impl<K, V> KeyedRef for BTreeMap<K, V> {
type KeyRef<'a> = &'a K where Self: 'a;
crate::covariant_key_ref!();
}
impl<K, V> Len for BTreeMap<K, V> {
#[inline(always)]
fn len(&self) -> usize {
self.len()
}
#[inline(always)]
fn is_empty(&self) -> bool {
self.is_empty()
}
}
impl<'a, Q, K: Ord, V> Get<&'a Q> for BTreeMap<K, V>
where
K: Borrow<Q>,
Q: Ord + ?Sized,
{
#[inline(always)]
fn get(&self, key: &'a Q) -> Option<&V> {
self.get(key)
}
}
impl<'a, Q, K: Ord, V> GetKeyValue<&'a Q> for BTreeMap<K, V>
where
K: Borrow<Q>,
Q: Ord + ?Sized,
{
#[inline(always)]
fn get_key_value(&self, key: &'a Q) -> Option<(&K, &V)> {
self.get_key_value(key)
}
}
impl<'a, Q, K: Ord, V> GetMut<&'a Q> for BTreeMap<K, V>
where
K: Borrow<Q>,
Q: Ord + ?Sized,
{
#[inline(always)]
fn get_mut(&mut self, key: &'a Q) -> Option<&mut V> {
self.get_mut(key)
}
}
impl<K: Ord, V> MapInsert<K> for BTreeMap<K, V> {
type Output = Option<V>;
#[inline(always)]
fn insert(&mut self, key: K, value: V) -> Option<V> {
self.insert(key, value)
}
}
impl<'a, Q, K: Ord, V> Remove<&'a Q> for BTreeMap<K, V>
where
K: Borrow<Q>,
Q: Ord + ?Sized,
{
#[inline(always)]
fn remove(&mut self, key: &'a Q) -> Option<V> {
self.remove(key)
}
}
impl<K: Ord, V> Clear for BTreeMap<K, V> {
#[inline(always)]
fn clear(&mut self) {
self.clear()
}
}
impl<K, V> Iter for BTreeMap<K, V> {
type Iter<'a> = std::collections::btree_map::Values<'a, K, V> where Self: 'a;
#[inline(always)]
fn iter(&self) -> Self::Iter<'_> {
self.values()
}
}
impl<K, V> MapIter for BTreeMap<K, V> {
type Iter<'a> = std::collections::btree_map::Iter<'a, K, V> where Self: 'a;
#[inline(always)]
fn iter(&self) -> Self::Iter<'_> {
self.iter()
}
}
impl<K, V> MapIterMut for BTreeMap<K, V> {
type IterMut<'a> = std::collections::btree_map::IterMut<'a, K, V> where Self: 'a;
#[inline(always)]
fn iter_mut(&mut self) -> Self::IterMut<'_> {
self.iter_mut()
}
}