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.
Shared EntitySet
implementation for all value types.
43
44
45
46
47
48
pub fn with_capacity(capacity: usize) -> Self {
Self {
elems: Vec::with_capacity((capacity + 7) / 8),
..Self::new()
}
}
Creates a new empty set with the specified capacity.
Get the element at k
if it exists.
103
104
105
106
107
108
109
110
111
pub fn insert(&mut self, k: K) -> bool {
let index = k.index();
if index >= self.len {
self.resize(index + 1)
}
let result = !self.contains(k);
self.elems[index / 8] |= 1 << (index % 8);
result
}
Is this set completely empty?
Returns the cardinality of the set. More precisely, it returns the number of calls to
insert
with different key values, that have happened since the the set was most recently
clear
ed or created with new
.
Remove all entries from this set.
Iterate over all the keys in this set.
Resize the set to have n
entries by adding default entries as needed.
103
104
105
106
107
108
109
110
111
pub fn insert(&mut self, k: K) -> bool {
let index = k.index();
if index >= self.len {
self.resize(index + 1)
}
let result = !self.contains(k);
self.elems[index / 8] |= 1 << (index % 8);
result
}
Removes and returns the entity from the set if it exists.
Performs copy-assignment from
source
.
Read more
Formats the value using the given formatter.
Read more
Returns the “default value” for a type.
Read more
Immutably borrows from an owned value.
Read more
Mutably borrows from an owned value.
Read more
Returns the argument unchanged.
Calls U::from(self)
.
That is, this conversion is whatever the implementation of
From<T> for U
chooses to do.
The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning.
Read more
Uses borrowed data to replace owned data, usually by cloning.
Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.