pub struct BloomFilter<const N: usize, const K: usize = 2> { /* private fields */ }Expand description
A Bloom filter, parameterized by number of u64 segments N and number of hash functions K.
N should be based on how much you plan to insert into the filter.
N * 64 should be at least the number of items you plan to insert.
K if how little you can tolerate false positives.
2, the default, should work for most uses. Increase K to reduce false positives,
at a pretty large compute cost.
§Examples
use bevy_utils::BloomFilter;
let mut filter = BloomFilter::<1>::new();
filter.insert(&"hello");
assert!(filter.contains(&"hello"));
assert!(!filter.contains(&"world"));Implementations§
Source§impl<const N: usize, const K: usize> BloomFilter<N, K>
impl<const N: usize, const K: usize> BloomFilter<N, K>
Sourcepub const fn new() -> BloomFilter<N, K>
pub const fn new() -> BloomFilter<N, K>
Creates a new, empty filter.
Sourcepub fn check_insert(&mut self, item: &impl Hash) -> bool
pub fn check_insert(&mut self, item: &impl Hash) -> bool
Combined Self::contains and Self::insert.
Returns true if the value was already in the filter.
Adds the value to the filter if it was not already present.
Trait Implementations§
Source§impl<const N: usize, const K: usize> Clone for BloomFilter<N, K>
impl<const N: usize, const K: usize> Clone for BloomFilter<N, K>
Source§fn clone(&self) -> BloomFilter<N, K>
fn clone(&self) -> BloomFilter<N, K>
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl<const N: usize, const K: usize> Default for BloomFilter<N, K>
impl<const N: usize, const K: usize> Default for BloomFilter<N, K>
Source§fn default() -> BloomFilter<N, K>
fn default() -> BloomFilter<N, K>
Returns the “default value” for a type. Read more
impl<const N: usize, const K: usize> Copy for BloomFilter<N, K>
Auto Trait Implementations§
impl<const N: usize, const K: usize> Freeze for BloomFilter<N, K>
impl<const N: usize, const K: usize> RefUnwindSafe for BloomFilter<N, K>
impl<const N: usize, const K: usize> Send for BloomFilter<N, K>
impl<const N: usize, const K: usize> Sync for BloomFilter<N, K>
impl<const N: usize, const K: usize> Unpin for BloomFilter<N, K>
impl<const N: usize, const K: usize> UnsafeUnpin for BloomFilter<N, K>
impl<const N: usize, const K: usize> UnwindSafe for BloomFilter<N, K>
Blanket Implementations§
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
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Converts
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be
downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Converts
Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further
downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Converts
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Converts
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSend for T
impl<T> DowncastSend for T
Source§impl<T> FromTemplate for T
impl<T> FromTemplate for T
Source§impl<T> FromWorld for Twhere
T: Default,
impl<T> FromWorld for Twhere
T: Default,
Source§fn from_world(_world: &mut World) -> T
fn from_world(_world: &mut World) -> T
Creates Self using default().
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> IntoResult<T> for T
impl<T> IntoResult<T> for T
Source§fn into_result(self) -> Result<T, RunSystemError>
fn into_result(self) -> Result<T, RunSystemError>
Converts this type into the system output type.
Source§impl<T> Template for T
impl<T> Template for T
Source§fn build_template(
&self,
_context: &mut TemplateContext<'_, '_>,
) -> Result<<T as Template>::Output, BevyError>
fn build_template( &self, _context: &mut TemplateContext<'_, '_>, ) -> Result<<T as Template>::Output, BevyError>
Uses this template and the given
entity context to produce a Template::Output.Source§fn clone_template(&self) -> T
fn clone_template(&self) -> T
Clones this template. See
Clone.Source§impl<T> TypeData for T
impl<T> TypeData for T
Source§fn clone_type_data(&self) -> Box<dyn TypeData>
fn clone_type_data(&self) -> Box<dyn TypeData>
Creates a type-erased clone of this value.