Struct EntitySet
pub struct EntitySet<K>where
K: EntityRef,{ /* private fields */ }Expand description
A set of K for densely indexed entity references.
The EntitySet data structure uses the dense index space to implement a set with a bitvector.
Like SecondaryMap, an EntitySet is used to associate secondary information with entities.
Implementations§
§impl<K> EntitySet<K>where
K: EntityRef,
Shared EntitySet implementation for all value types.
impl<K> EntitySet<K>where
K: EntityRef,
Shared EntitySet implementation for all value types.
pub fn with_capacity(capacity: usize) -> EntitySet<K>
pub fn with_capacity(capacity: usize) -> EntitySet<K>
Creates a new empty set with the specified capacity.
pub fn ensure_capacity(&mut self, capacity: usize)
pub fn ensure_capacity(&mut self, capacity: usize)
Ensure that the set has enough capacity to hold capacity total
elements.
pub fn clear(&mut self)
pub fn clear(&mut self)
Remove all entries from this set.
pub fn keys(&self) -> Keys<K> ⓘ
pub fn keys(&self) -> Keys<K> ⓘ
Iterate over all the keys up to the maximum in this set.
This will yield intermediate keys on the way up to the max key, even if they are not contained within the set.
use cranelift_entity::{entity_impl, EntityRef, EntitySet};
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
struct Entity(u32);
entity_impl!(Entity);
let mut set = EntitySet::new();
set.insert(Entity::new(2));
let mut keys = set.keys();
assert_eq!(keys.next(), Some(Entity::new(0)));
assert_eq!(keys.next(), Some(Entity::new(1)));
assert_eq!(keys.next(), Some(Entity::new(2)));
assert!(keys.next().is_none());pub fn iter(&self) -> SetIter<'_, K> ⓘ
pub fn iter(&self) -> SetIter<'_, K> ⓘ
Iterate over the elements of this set.
use cranelift_entity::{entity_impl, EntityRef, EntitySet};
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
struct Entity(u32);
entity_impl!(Entity);
let mut set = EntitySet::new();
set.insert(Entity::new(2));
set.insert(Entity::new(3));
let mut iter = set.iter();
assert_eq!(iter.next(), Some(Entity::new(2)));
assert_eq!(iter.next(), Some(Entity::new(3)));
assert!(iter.next().is_none());pub fn insert(&mut self, k: K) -> bool
pub fn insert(&mut self, k: K) -> bool
Insert the element at k.
Returns true if k was not present in the set, i.e. this is a
newly-added element. Returns false otherwise.
Trait Implementations§
§impl<'de, K> Deserialize<'de> for EntitySet<K>where
K: EntityRef,
impl<'de, K> Deserialize<'de> for EntitySet<K>where
K: EntityRef,
§fn deserialize<__D>(
__deserializer: __D,
) -> Result<EntitySet<K>, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<EntitySet<K>, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
§impl<K> Extend<K> for EntitySet<K>where
K: EntityRef,
impl<K> Extend<K> for EntitySet<K>where
K: EntityRef,
§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> Serialize for EntitySet<K>where
K: EntityRef,
impl<K> Serialize for EntitySet<K>where
K: EntityRef,
§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
impl<K> Eq for EntitySet<K>
impl<K> StructuralPartialEq for EntitySet<K>where
K: EntityRef,
Auto Trait Implementations§
impl<K> Freeze for EntitySet<K>
impl<K> RefUnwindSafe for EntitySet<K>where
K: RefUnwindSafe,
impl<K> Send for EntitySet<K>where
K: Send,
impl<K> Sync for EntitySet<K>where
K: Sync,
impl<K> Unpin for EntitySet<K>where
K: Unpin,
impl<K> UnwindSafe for EntitySet<K>where
K: UnwindSafe,
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.