Struct wgpu_core::identity::IdentityValues
source · pub(crate) struct IdentityValues {
free: Vec<(u32, u32)>,
next_index: u32,
count: usize,
id_source: IdSource,
}
Expand description
A simple structure to allocate Id
identifiers.
Calling alloc
returns a fresh, never-before-seen id. Calling release
marks an id as dead; it will never be returned again by alloc
.
IdentityValues
returns Id
s whose index values are suitable for use as
indices into a Vec<T>
that holds those ids’ referents:
-
Every live id has a distinct index value. Every live id’s index selects a distinct element in the vector.
-
IdentityValues
prefers low index numbers. If you size your vector to accommodate the indices produced here, the vector’s length will reflect the highwater mark of actual occupancy. -
IdentityValues
reuses the index values of freed ids before returning ids with new index values. Freed vector entries get reused.
Fields§
§free: Vec<(u32, u32)>
§next_index: u32
§count: usize
§id_source: IdSource
Implementations§
source§impl IdentityValues
impl IdentityValues
sourcepub fn alloc<T: Marker>(&mut self) -> Id<T>
pub fn alloc<T: Marker>(&mut self) -> Id<T>
Allocate a fresh, never-before-seen id with the given backend
.
The backend is incorporated into the id, so that ids allocated with
different backend
values are always distinct.
pub fn mark_as_used<T: Marker>(&mut self, id: Id<T>) -> Id<T>
sourcepub fn release<T: Marker>(&mut self, id: Id<T>)
pub fn release<T: Marker>(&mut self, id: Id<T>)
Free id
. It will never be returned from alloc
again.