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
use core::hash::{Hash, BuildHasher}; use core::borrow::Borrow; #[cfg(feature = "use_std")] use std::collections::hash_set::HashSet; #[cfg(not(feature = "use_std"))] use hashmap_core::HashSet; use super::super::*; impl<V, S> Collection for HashSet<V, S> where V: Eq + Hash, S: BuildHasher, { #[inline(always)] fn len(&self) -> usize { HashSet::<V, S>::len(self) } } impl<V, S> CollectionMut for HashSet<V, S> where V: Eq + Hash, S: BuildHasher, { #[inline(always)] fn clear(&mut self) { HashSet::<V, S>::drain(self); } } impl<V, S> Create<V> for HashSet<V, S> where V: Eq + Hash, S: Default + BuildHasher, { #[inline(always)] fn create() -> Self { HashSet::<V, S>::default() } #[inline(always)] fn create_with_capacity(_: usize) -> Self { HashSet::<V, S>::default() } #[inline(always)] fn add_element(mut self, value: V) -> Self { HashSet::<V, S>::insert(&mut self, value); self } } impl<'a, Q, V> Get<&'a Q> for HashSet<V> where Q: Eq + Hash + ?Sized, V: Eq + Hash + Borrow<Q>, { type Output = V; #[inline(always)] fn get(&self, q: &Q) -> Option<&Self::Output> { HashSet::get(self, q) } }