Struct froggy::Storage
[−]
[src]
pub struct Storage<T> { /* fields omitted */ }
Component storage type. Manages the components and allows for efficient processing. See also: Pointer
Examples
let mut storage = Storage::new(); // add component to storage let pointer = storage.create(1u32); // change component by pointer storage[&pointer] = 30;
Methods
impl<T> Storage<T>
[src]
fn new() -> Storage<T>
[src]
Create a new empty storage.
fn with_capacity(capacity: usize) -> Storage<T>
[src]
Create a new empty storage with specified capacity.
fn sync_pending(&mut self)
[src]
Synchronize for all the pending updates.
It will update all reference counters in Storage, so
iter_alive
and
iter_alive_mut
will return actual information.
Use this function only if necessary, because it needs to block Storage.
fn iter(&self) -> Iter<T>
[src]
Iterate all components in this storage that are still referenced from outside.
Attention
Information about live components is updated not for all changes, but
only when you explicitly call sync_pending
.
It means, you can get wrong results when calling this function before updating pending.
fn iter_all(&self) -> Iter<T>
[src]
Iterate all components that are stored, even if not referenced.
This can be faster than the regular iter
for the lack of refcount checks.
fn iter_mut(&mut self) -> IterMut<T>
[src]
Iterate all components in this storage that are still referenced from outside, mutably.
Attention
Information about live components is updated not for all changes, but
only when you explicitly call sync_pending
.
It means, you can get wrong results when calling this function before updating pending.
fn iter_all_mut(&mut self) -> IterMut<T>
[src]
Iterate all components that are stored, even if not referenced, mutably.
This can be faster than the regular iter_mut
for the lack of refcount checks.
fn pin(&self, item: &Item<T>) -> Pointer<T>
[src]
Pin an iterated item with a newly created Pointer
.
fn split(&mut self, pointer: &Pointer<T>) -> (Slice<T>, &mut T, Slice<T>)
[src]
Split the storage according to the provided pointer, returning the (left slice, pointed data, right slice) triple, where: left slice contains all the elements that would be iterated prior to the given one, right slice contains all the elements that would be iterated after the given one
fn cursor(&mut self) -> Cursor<T>
[src]
Produce a streaming mutable iterator over components that are still referenced.
Attention
Information about live components is updated not for all changes, but
only when you explicitly call sync_pending
.
It means, you can get wrong results when calling this function before updating pending.
fn cursor_end(&mut self) -> Cursor<T>
[src]
Returns a cursor to the end of the storage, for backwards streaming iteration.
fn create(&mut self, value: T) -> Pointer<T>
[src]
Add a new component to the storage, returning the Pointer
to it.
Trait Implementations
impl<T: Debug> Debug for Storage<T>
[src]
impl<'a, T> Index<&'a Pointer<T>> for Storage<T>
[src]
type Output = T
The returned type after indexing.
fn index(&self, pointer: &'a Pointer<T>) -> &T
[src]
Performs the indexing (container[index]
) operation.
impl<'a, T> IndexMut<&'a Pointer<T>> for Storage<T>
[src]
fn index_mut(&mut self, pointer: &'a Pointer<T>) -> &mut T
[src]
Performs the mutable indexing (container[index]
) operation.
impl<T> FromIterator<T> for Storage<T>
[src]
fn from_iter<I>(iter: I) -> Self where
I: IntoIterator<Item = T>,
[src]
I: IntoIterator<Item = T>,
Creates a value from an iterator. Read more
impl<'a, T> IntoIterator for &'a Storage<T>
[src]
type Item = Item<'a, T>
The type of the elements being iterated over.
type IntoIter = Iter<'a, T>
Which kind of iterator are we turning this into?
fn into_iter(self) -> Self::IntoIter
[src]
Creates an iterator from a value. Read more
impl<'a, T> IntoIterator for &'a mut Storage<T>
[src]
type Item = &'a mut T
The type of the elements being iterated over.
type IntoIter = IterMut<'a, T>
Which kind of iterator are we turning this into?
fn into_iter(self) -> Self::IntoIter
[src]
Creates an iterator from a value. Read more