polars_utils/
aliases.rs

1pub type PlRandomState = ahash::RandomState;
2pub type PlRandomStateQuality = ahash::RandomState;
3
4pub type PlHashMap<K, V> = hashbrown::HashMap<K, V, PlRandomState>;
5pub type PlHashSet<V> = hashbrown::HashSet<V, PlRandomState>;
6pub type PlIndexMap<K, V> = indexmap::IndexMap<K, V, PlRandomState>;
7pub type PlIndexSet<K> = indexmap::IndexSet<K, PlRandomState>;
8
9pub trait InitHashMaps {
10    type HashMap;
11
12    fn new() -> Self::HashMap;
13
14    fn with_capacity(capacity: usize) -> Self::HashMap;
15}
16
17impl<K, V> InitHashMaps for PlHashMap<K, V> {
18    type HashMap = Self;
19
20    fn new() -> Self::HashMap {
21        Self::with_capacity_and_hasher(0, Default::default())
22    }
23
24    fn with_capacity(capacity: usize) -> Self {
25        Self::with_capacity_and_hasher(capacity, Default::default())
26    }
27}
28impl<K> InitHashMaps for PlHashSet<K> {
29    type HashMap = Self;
30
31    fn new() -> Self::HashMap {
32        Self::with_capacity_and_hasher(0, Default::default())
33    }
34
35    fn with_capacity(capacity: usize) -> Self {
36        Self::with_capacity_and_hasher(capacity, Default::default())
37    }
38}
39
40impl<K> InitHashMaps for PlIndexSet<K> {
41    type HashMap = Self;
42
43    fn new() -> Self::HashMap {
44        Self::with_capacity_and_hasher(0, Default::default())
45    }
46
47    fn with_capacity(capacity: usize) -> Self::HashMap {
48        Self::with_capacity_and_hasher(capacity, Default::default())
49    }
50}
51
52impl<K, V> InitHashMaps for PlIndexMap<K, V> {
53    type HashMap = Self;
54
55    fn new() -> Self::HashMap {
56        Self::with_capacity_and_hasher(0, Default::default())
57    }
58
59    fn with_capacity(capacity: usize) -> Self::HashMap {
60        Self::with_capacity_and_hasher(capacity, Default::default())
61    }
62}