wiwi/chain/hashbrown_hashmap.rs
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 150 151 152 153 154 155 156 157 158 159
extern crate hashbrown;
use crate::prelude::*;
use crate::macro_util::void;
use super::{ chain_fn, ChainInner as _, OutputStorage };
use hash::BuildHasher;
use hashbrown::{ DefaultHashBuilder, HashMap };
super::decl_chain! {
generics_decl: [K, V, S]
generics_decl_struct_def: [K, V, S = DefaultHashBuilder]
generics: [K, V, S]
chain: HashMapChain
inner: HashMap<K, V, S>
}
impl<K, V> HashMapChain<K, V> {
#[inline]
pub fn new() -> Self {
HashMap::new().into_chain()
}
#[inline]
pub fn new_with_capacity(capacity: usize) -> Self {
HashMap::with_capacity(capacity).into_chain()
}
}
impl<K, V, S> HashMapChain<K, V, S> {
#[inline]
pub fn new_with_hasher(hash_builder: S) -> Self {
HashMap::with_hasher(hash_builder).into_chain()
}
#[inline]
pub fn new_with_capacity_and_hasher(capacity: usize, hash_builder: S) -> Self {
HashMap::with_capacity_and_hasher(capacity, hash_builder).into_chain()
}
}
impl<K, V, S> HashMapChain<K, V, S> {
chain_fn! {
clear(inner)
=> inner.clear()
}
chain_fn! {
insert(inner, k: K, v: V) where {
K: Eq + Hash,
S: BuildHasher
} => void!(inner.insert(k, v))
}
chain_fn! {
insert_and_take_old[O](inner, k: K, v: V, out: O) where {
K: Eq + Hash,
S: BuildHasher,
O: OutputStorage<Option<V>>
} => {
// SAFETY: we always write once to `out`
unsafe { out.store(inner.insert(k, v)) }
}
}
}
/*
Methods
allocation_size
allocator
capacity
contains_key
drain
entry
entry_ref
extract_if
get
get_key_value
get_key_value_mut
get_many_key_value_mut
get_many_key_value_unchecked_mut
get_many_mut
get_many_unchecked_mut
get_mut
hasher
insert
insert_unique_unchecked
into_keys
into_values
is_empty
iter
iter_mut
keys
len
new
new_in
par_drain
par_eq
par_keys
par_values
par_values_mut
raw_entry
raw_entry_mut
remove
remove_entry
reserve
retain
shrink_to
shrink_to_fit
try_insert
try_reserve
values
values_mut
Trait Implementations
Clone
Debug
Default
Deserialize<'de>
Eq
Extend<&'a (K, V)>
Extend<(&'a K, &'a V)>
Extend<(K, V)>
From<HashMap<T, (), S, A>>
From<[(K, V); N]>
FromIterator<(K, V)>
FromParallelIterator<(K, V)>
Index<&Q>
IntoIterator
IntoIterator
IntoIterator
IntoParallelIterator
IntoParallelIterator
IntoParallelIterator
ParallelExtend<(&'a K, &'a V)>
ParallelExtend<(K, V)>
PartialEq
Serialize
Auto Trait Implementations
Freeze
RefUnwindSafe
Send
Sync
Unpin
UnwindSafe
Blanket Implementations
Any
Borrow<T>
BorrowMut<T>
CloneToUninit
DeserializeOwned
Equivalent<K>
From<T>
Into<U>
IntoParallelRefIterator<'data>
IntoParallelRefMutIterator<'data>
Pointable
ToOwned
TryFrom<U>
TryInto<U>
*/