pub struct EntryMap {
inner: IndexMap<u32, BindGroupLayoutEntry, BuildHasherDefault<FxHasher>>,
sorted: bool,
}
Expand description
A HashMap-like structure that stores a BindGroupLayouts wgt::BindGroupLayoutEntry
s.
It is hashable, so bind group layouts can be deduplicated.
Fields§
§inner: IndexMap<u32, BindGroupLayoutEntry, BuildHasherDefault<FxHasher>>
We use a IndexMap here so that we can sort the entries by their binding index, guaranteeing that the hash of equivalent layouts will be the same.
sorted: bool
We keep track of whether the map is sorted or not, so that we can assert that it is sorted, so that PartialEq and Hash will be stable.
We only need sorted if it is used in a Hash or PartialEq, so we never need to actively sort it.
Implementations§
source§impl EntryMap
impl EntryMap
fn assert_sorted(&self)
sourcepub fn from_entries(
device_limits: &Limits,
entries: &[BindGroupLayoutEntry],
) -> Result<Self, CreateBindGroupLayoutError>
pub fn from_entries( device_limits: &Limits, entries: &[BindGroupLayoutEntry], ) -> Result<Self, CreateBindGroupLayoutError>
Create a new EntryMap
from a slice of wgt::BindGroupLayoutEntry
s.
Errors if there are duplicate bindings or if any binding index is greater than the device’s limits.
sourcepub fn len(&self) -> usize
pub fn len(&self) -> usize
Get the count of wgt::BindGroupLayoutEntry
s in this map.
sourcepub fn get(&self, binding: u32) -> Option<&BindGroupLayoutEntry>
pub fn get(&self, binding: u32) -> Option<&BindGroupLayoutEntry>
Get the wgt::BindGroupLayoutEntry
for the given binding index.
sourcepub fn indices(&self) -> impl ExactSizeIterator<Item = u32> + '_
pub fn indices(&self) -> impl ExactSizeIterator<Item = u32> + '_
Iterator over all the binding indices in this map.
sourcepub fn values(
&self,
) -> impl ExactSizeIterator<Item = &BindGroupLayoutEntry> + '_
pub fn values( &self, ) -> impl ExactSizeIterator<Item = &BindGroupLayoutEntry> + '_
Iterator over all the wgt::BindGroupLayoutEntry
s in this map.
pub fn iter( &self, ) -> impl ExactSizeIterator<Item = (&u32, &BindGroupLayoutEntry)> + '_
pub fn is_empty(&self) -> bool
pub fn contains_key(&self, key: u32) -> bool
pub fn entry(&mut self, key: u32) -> Entry<'_, u32, BindGroupLayoutEntry>
pub fn sort(&mut self)
Trait Implementations§
impl Eq for EntryMap
Auto Trait Implementations§
impl Freeze for EntryMap
impl RefUnwindSafe for EntryMap
impl Send for EntryMap
impl Sync for EntryMap
impl Unpin for EntryMap
impl UnwindSafe for EntryMap
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,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.