pub type ValueList = EntityList<Value>;
Expand description
Some instructions use an external list of argument values because there is not enough space in
the 16-byte InstructionData
struct. These value lists are stored in a memory pool in
dfg.value_lists
.
Aliased Type§
struct ValueList { /* private fields */ }
Implementations
Source§impl<T> EntityList<T>where
T: EntityRef + ReservedValue,
impl<T> EntityList<T>where
T: EntityRef + ReservedValue,
Sourcepub fn new() -> EntityList<T>
pub fn new() -> EntityList<T>
Create a new empty list.
Sourcepub fn from_slice(slice: &[T], pool: &mut ListPool<T>) -> EntityList<T>
pub fn from_slice(slice: &[T], pool: &mut ListPool<T>) -> EntityList<T>
Create a new list with the contents initialized from a slice.
Sourcepub fn get(&self, index: usize, pool: &ListPool<T>) -> Option<T>
pub fn get(&self, index: usize, pool: &ListPool<T>) -> Option<T>
Get a single element from the list.
Sourcepub fn as_mut_slice<'a>(&'a mut self, pool: &'a mut ListPool<T>) -> &'a mut [T]
pub fn as_mut_slice<'a>(&'a mut self, pool: &'a mut ListPool<T>) -> &'a mut [T]
Get the list as a mutable slice.
Sourcepub fn get_mut<'a>(
&'a mut self,
index: usize,
pool: &'a mut ListPool<T>,
) -> Option<&'a mut T>
pub fn get_mut<'a>( &'a mut self, index: usize, pool: &'a mut ListPool<T>, ) -> Option<&'a mut T>
Get a mutable reference to a single element from the list.
Sourcepub fn deep_clone(&self, pool: &mut ListPool<T>) -> EntityList<T>
pub fn deep_clone(&self, pool: &mut ListPool<T>) -> EntityList<T>
Create a deep clone of the list, which does not alias the original list.
Sourcepub fn clear(&mut self, pool: &mut ListPool<T>)
pub fn clear(&mut self, pool: &mut ListPool<T>)
Removes all elements from the list.
The memory used by the list is put back in the pool.
Sourcepub fn take(&mut self) -> EntityList<T>
pub fn take(&mut self) -> EntityList<T>
Take all elements from this list and return them as a new list. Leave this list empty.
This is the equivalent of Option::take()
.
Sourcepub fn push(&mut self, element: T, pool: &mut ListPool<T>) -> usize
pub fn push(&mut self, element: T, pool: &mut ListPool<T>) -> usize
Appends an element to the back of the list. Returns the index where the element was inserted.
Sourcepub fn from_iter<I>(elements: I, pool: &mut ListPool<T>) -> EntityList<T>where
I: IntoIterator<Item = T>,
pub fn from_iter<I>(elements: I, pool: &mut ListPool<T>) -> EntityList<T>where
I: IntoIterator<Item = T>,
Constructs a list from an iterator.
Sourcepub fn extend<I>(&mut self, elements: I, pool: &mut ListPool<T>)where
I: IntoIterator<Item = T>,
pub fn extend<I>(&mut self, elements: I, pool: &mut ListPool<T>)where
I: IntoIterator<Item = T>,
Appends multiple elements to the back of the list.
Sourcepub fn copy_from(
&mut self,
other: &EntityList<T>,
slice: impl RangeBounds<usize>,
index: usize,
pool: &mut ListPool<T>,
)
pub fn copy_from( &mut self, other: &EntityList<T>, slice: impl RangeBounds<usize>, index: usize, pool: &mut ListPool<T>, )
Copies a slice from an entity list in the same pool to a position in this one.
Will panic if self
is the same list as other
.
Sourcepub fn insert(&mut self, index: usize, element: T, pool: &mut ListPool<T>)
pub fn insert(&mut self, index: usize, element: T, pool: &mut ListPool<T>)
Inserts an element as position index
in the list, shifting all elements after it to the
right.
Sourcepub fn remove(&mut self, index: usize, pool: &mut ListPool<T>)
pub fn remove(&mut self, index: usize, pool: &mut ListPool<T>)
Removes the element at position index
from the list. Potentially linear complexity.
Sourcepub fn swap_remove(&mut self, index: usize, pool: &mut ListPool<T>)
pub fn swap_remove(&mut self, index: usize, pool: &mut ListPool<T>)
Removes the element at index
in constant time by switching it with the last element of
the list.
Sourcepub fn truncate(&mut self, new_len: usize, pool: &mut ListPool<T>)
pub fn truncate(&mut self, new_len: usize, pool: &mut ListPool<T>)
Shortens the list down to len
elements.
Does nothing if the list is already shorter than len
.
Sourcepub fn grow_at(&mut self, index: usize, count: usize, pool: &mut ListPool<T>)
pub fn grow_at(&mut self, index: usize, count: usize, pool: &mut ListPool<T>)
Grow the list by inserting count
elements at index
.
The new elements are not initialized, they will contain whatever happened to be in memory. Since the memory comes from the pool, this will be either zero entity references or whatever where in a previously deallocated list.
Trait Implementations
Source§impl<T> Clone for EntityList<T>
impl<T> Clone for EntityList<T>
Source§fn clone(&self) -> EntityList<T>
fn clone(&self) -> EntityList<T>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl<T> Debug for EntityList<T>
impl<T> Debug for EntityList<T>
Source§impl<T> Default for EntityList<T>where
T: EntityRef + ReservedValue,
Create an empty list.
impl<T> Default for EntityList<T>where
T: EntityRef + ReservedValue,
Create an empty list.