[][src]Trait purezen::allocator::Allocator

pub trait Allocator<T: Allocated>: Index<T::Id> + IndexMut<T::Id> {
    fn allocate<F>(&mut self, f: F) -> &mut T
    where
        F: Fn(T::Id) -> T
;
fn get(&self, id: T::Id) -> Option<&T>;
fn get_mut(&mut self, id: T::Id) -> Option<&mut T>; }

Indexed memory allocator providing O(1) access to contained values by a T::Id type.

Required methods

Important traits for &'_ mut I
fn allocate<F>(&mut self, f: F) -> &mut T where
    F: Fn(T::Id) -> T, 

Allocate a slot in the buffer and call the given function to get a value

Panics if there is no space available in the buffer.

fn get(&self, id: T::Id) -> Option<&T>

Get an object located at the given slot ID.

fn get_mut(&mut self, id: T::Id) -> Option<&mut T>

Get a mutable reference to an object located at the given slot ID.

Loading content...

Implementors

impl<T, N> Allocator<T> for FixedSizeAllocator<T, N> where
    T: Allocated,
    N: ArrayLength<Option<T>>, 
[src]

Important traits for &'_ mut I
fn allocate<F>(&mut self, f: F) -> &mut T where
    F: Fn(T::Id) -> T, 
[src]

Allocate a slot in the buffer and call the given function to get a value

Panics if there is no space available in the buffer.

fn get(&self, id: T::Id) -> Option<&T>[src]

Get value located at the given slot ID.

fn get_mut(&mut self, id: T::Id) -> Option<&mut T>[src]

Get a mutable reference to an value located at the given slot ID.

Loading content...