Type Definition bevy_utils::HashSet[][src]

pub type HashSet<K> = HashSet<K, RandomState>;
Expand description

A HashSet implementing aHash, a high speed keyed hashing algorithm intended for use in in-memory hashmaps.

aHash is designed for performance and is NOT cryptographically secure.

Construction

Users may be surprised when a HashSet cannot be constructed with HashSet::new():

use bevy_utils::HashSet;

// Produces an error like "no function or associated item named `new` found [...]"
let map: HashSet<String> = HashSet::new();

The standard library’s HashSet::new is implemented only for HashSets which use the DefaultHasher, so it’s not available for Bevy’s HashSet.

However, an empty HashSet can easily be constructed using the Default implementation:

use bevy_utils::HashSet;

// This works!
let map: HashSet<String> = HashSet::default();
assert!(map.is_empty());

Trait Implementations

Creates an empty HashSet with the specified capacity with aHash.

The hash set will be able to hold at least capacity elements without reallocating. If capacity is 0, the hash set will not allocate.

Examples
use bevy_utils::{HashSet, AHashExt};
let set: HashSet<i32> = HashSet::with_capacity(10);
assert!(set.capacity() >= 10);