Struct bones_framework::asset::prelude::dashmap::DashSet
pub struct DashSet<K, S = RandomState> { /* private fields */ }
Expand description
DashSet is a thin wrapper around DashMap
using ()
as the value type. It uses
methods and types which are more convenient to work with on a set.
Implementations§
§impl<'a, K> DashSet<K>
impl<'a, K> DashSet<K>
pub fn new() -> DashSet<K>
pub fn new() -> DashSet<K>
Creates a new DashSet with a capacity of 0.
§Examples
use dashmap::DashSet;
let games = DashSet::new();
games.insert("Veloren");
pub fn with_capacity(capacity: usize) -> DashSet<K>
pub fn with_capacity(capacity: usize) -> DashSet<K>
Creates a new DashMap with a specified starting capacity.
§Examples
use dashmap::DashSet;
let numbers = DashSet::with_capacity(2);
numbers.insert(2);
numbers.insert(8);
§impl<'a, K, S> DashSet<K, S>
impl<'a, K, S> DashSet<K, S>
pub fn with_hasher(hasher: S) -> DashSet<K, S>
pub fn with_hasher(hasher: S) -> DashSet<K, S>
Creates a new DashMap with a capacity of 0 and the provided hasher.
§Examples
use dashmap::DashSet;
use std::collections::hash_map::RandomState;
let s = RandomState::new();
let games = DashSet::with_hasher(s);
games.insert("Veloren");
pub fn with_capacity_and_hasher(capacity: usize, hasher: S) -> DashSet<K, S>
pub fn with_capacity_and_hasher(capacity: usize, hasher: S) -> DashSet<K, S>
Creates a new DashMap with a specified starting capacity and hasher.
§Examples
use dashmap::DashSet;
use std::collections::hash_map::RandomState;
let s = RandomState::new();
let numbers = DashSet::with_capacity_and_hasher(2, s);
numbers.insert(2);
numbers.insert(8);
pub fn hash_usize<T>(&self, item: &T) -> usizewhere
T: Hash,
pub fn hash_usize<T>(&self, item: &T) -> usizewhere
T: Hash,
Hash a given item to produce a usize. Uses the provided or default HashBuilder.
pub fn insert(&self, key: K) -> bool
pub fn insert(&self, key: K) -> bool
Inserts a key into the set. Returns true if the key was not already in the set.
§Examples
use dashmap::DashSet;
let set = DashSet::new();
set.insert("I am the key!");
pub fn remove<Q>(&self, key: &Q) -> Option<K>
pub fn remove<Q>(&self, key: &Q) -> Option<K>
Removes an entry from the map, returning the key if it existed in the map.
§Examples
use dashmap::DashSet;
let soccer_team = DashSet::new();
soccer_team.insert("Jack");
assert_eq!(soccer_team.remove("Jack").unwrap(), "Jack");
pub fn remove_if<Q>(&self, key: &Q, f: impl FnOnce(&K) -> bool) -> Option<K>
pub fn remove_if<Q>(&self, key: &Q, f: impl FnOnce(&K) -> bool) -> Option<K>
Removes an entry from the set, returning the key if the entry existed and the provided conditional function returned true.
use dashmap::DashSet;
let soccer_team = DashSet::new();
soccer_team.insert("Sam");
soccer_team.remove_if("Sam", |player| player.starts_with("Ja"));
assert!(soccer_team.contains("Sam"));
use dashmap::DashSet;
let soccer_team = DashSet::new();
soccer_team.insert("Sam");
soccer_team.remove_if("Jacob", |player| player.starts_with("Ja"));
assert!(!soccer_team.contains("Jacob"));
pub fn iter(&'a self) -> Iter<'a, K, S, DashMap<K, (), S>> ⓘ
pub fn iter(&'a self) -> Iter<'a, K, S, DashMap<K, (), S>> ⓘ
Creates an iterator over a DashMap yielding immutable references.
§Examples
use dashmap::DashSet;
let words = DashSet::new();
words.insert("hello");
assert_eq!(words.iter().count(), 1);
pub fn get<Q>(&'a self, key: &Q) -> Option<Ref<'a, K, S>>
pub fn get<Q>(&'a self, key: &Q) -> Option<Ref<'a, K, S>>
Get a reference to an entry in the set
§Examples
use dashmap::DashSet;
let youtubers = DashSet::new();
youtubers.insert("Bosnian Bill");
assert_eq!(*youtubers.get("Bosnian Bill").unwrap(), "Bosnian Bill");
pub fn shrink_to_fit(&self)
pub fn shrink_to_fit(&self)
Remove excess capacity to reduce memory usage.
pub fn retain(&self, f: impl FnMut(&K) -> bool)
pub fn retain(&self, f: impl FnMut(&K) -> bool)
Retain elements that whose predicates return true and discard elements whose predicates return false.
§Examples
use dashmap::DashSet;
let people = DashSet::new();
people.insert("Albin");
people.insert("Jones");
people.insert("Charlie");
people.retain(|name| name.contains('i'));
assert_eq!(people.len(), 2);
pub fn len(&self) -> usize
pub fn len(&self) -> usize
Fetches the total number of keys stored in the set.
§Examples
use dashmap::DashSet;
let people = DashSet::new();
people.insert("Albin");
people.insert("Jones");
people.insert("Charlie");
assert_eq!(people.len(), 3);
pub fn is_empty(&self) -> bool
pub fn is_empty(&self) -> bool
Checks if the set is empty or not.
§Examples
use dashmap::DashSet;
let map = DashSet::<()>::new();
assert!(map.is_empty());
Trait Implementations§
§impl<K, S> Extend<K> for DashSet<K, S>
impl<K, S> Extend<K> for DashSet<K, S>
§fn extend<T>(&mut self, iter: T)where
T: IntoIterator<Item = K>,
fn extend<T>(&mut self, iter: T)where
T: IntoIterator<Item = K>,
source§fn extend_one(&mut self, item: A)
fn extend_one(&mut self, item: A)
extend_one
)source§fn extend_reserve(&mut self, additional: usize)
fn extend_reserve(&mut self, additional: usize)
extend_one
)§impl<K, S> FromIterator<K> for DashSet<K, S>
impl<K, S> FromIterator<K> for DashSet<K, S>
§fn from_iter<I>(iter: I) -> DashSet<K, S>where
I: IntoIterator<Item = K>,
fn from_iter<I>(iter: I) -> DashSet<K, S>where
I: IntoIterator<Item = K>,
§impl<K, S> IntoIterator for DashSet<K, S>
impl<K, S> IntoIterator for DashSet<K, S>
Auto Trait Implementations§
impl<K, S> Freeze for DashSet<K, S>where
S: Freeze,
impl<K, S = RandomState> !RefUnwindSafe for DashSet<K, S>
impl<K, S> Send for DashSet<K, S>
impl<K, S> Sync for DashSet<K, S>
impl<K, S> Unpin for DashSet<K, S>where
S: Unpin,
impl<K, S> UnwindSafe for DashSet<K, S>where
S: UnwindSafe,
K: UnwindSafe,
Blanket Implementations§
§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> CheckedSum<usize> for Twhere
T: IntoIterator<Item = usize>,
impl<T> CheckedSum<usize> for Twhere
T: IntoIterator<Item = usize>,
§fn checked_sum(self) -> Result<usize, Error>
fn checked_sum(self) -> Result<usize, Error>
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§default unsafe fn clone_to_uninit(&self, dst: *mut T)
default unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)§impl<T> Conv for T
impl<T> Conv for T
§impl<T> FmtForward for T
impl<T> FmtForward for T
§fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
self
to use its Binary
implementation when Debug
-formatted.§fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
self
to use its Display
implementation when
Debug
-formatted.§fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
self
to use its LowerExp
implementation when
Debug
-formatted.§fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
self
to use its LowerHex
implementation when
Debug
-formatted.§fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
self
to use its Octal
implementation when Debug
-formatted.§fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
self
to use its Pointer
implementation when
Debug
-formatted.§fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
self
to use its UpperExp
implementation when
Debug
-formatted.§fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
self
to use its UpperHex
implementation when
Debug
-formatted.§fn fmt_list(self) -> FmtList<Self>where
&'a Self: for<'a> IntoIterator,
fn fmt_list(self) -> FmtList<Self>where
&'a Self: for<'a> IntoIterator,
§impl<S> FromSample<S> for S
impl<S> FromSample<S> for S
fn from_sample_(s: S) -> S
source§impl<T> FromWorld for Twhere
T: Default,
impl<T> FromWorld for Twhere
T: Default,
source§fn from_world(_world: &World) -> T
fn from_world(_world: &World) -> T
Self
using data from the given World
.§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
§impl<F, T> IntoSample<T> for Fwhere
T: FromSample<F>,
impl<F, T> IntoSample<T> for Fwhere
T: FromSample<F>,
fn into_sample(self) -> T
§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
self
and passes that borrow into the pipe function. Read more§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
self
and passes that borrow into the pipe function. Read more§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R,
) -> R
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
self
, then passes self.as_ref()
into the pipe function.§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
self
, then passes self.as_mut()
into the pipe
function.§fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
self
, then passes self.deref()
into the pipe function.source§impl<T> RawDefault for Twhere
T: Default,
impl<T> RawDefault for Twhere
T: Default,
§impl<T> Tap for T
impl<T> Tap for T
§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
Borrow<B>
of a value. Read more§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
BorrowMut<B>
of a value. Read more§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
AsRef<R>
view of a value. Read more§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
AsMut<R>
view of a value. Read more§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
Deref::Target
of a value. Read more§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
Deref::Target
of a value. Read more§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
.tap()
only in debug builds, and is erased in release builds.§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
.tap_mut()
only in debug builds, and is erased in release
builds.§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
.tap_borrow()
only in debug builds, and is erased in release
builds.§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
.tap_borrow_mut()
only in debug builds, and is erased in release
builds.§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
.tap_ref()
only in debug builds, and is erased in release
builds.§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
.tap_ref_mut()
only in debug builds, and is erased in release
builds.§fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
.tap_deref()
only in debug builds, and is erased in release
builds.