Struct crayon::utils::object_pool::ObjectPool
[−]
[src]
pub struct ObjectPool<T: Sized> { /* fields omitted */ }
A named object collections. Every time u create or free a handle, a
attached instance T
will be created/ freed.
Methods
impl<T: Sized> ObjectPool<T>
[src]
fn new() -> Self
[src]
Constructs a new, empty ObjectPool
.
fn with_capacity(capacity: usize) -> Self
[src]
Constructs a new ObjectPool
with the specified capacity.
fn create(&mut self, value: T) -> Handle
[src]
Creates a T
and named it with Handle
.
fn get_mut<H>(&mut self, handle: H) -> Option<&mut T> where
H: Borrow<Handle>,
[src]
H: Borrow<Handle>,
Returns mutable reference to internal value with name Handle
.
fn get<H>(&self, handle: H) -> Option<&T> where
H: Borrow<Handle>,
[src]
H: Borrow<Handle>,
Returns immutable reference to internal value with name Handle
.
fn is_alive<H>(&self, handle: H) -> bool where
H: Borrow<Handle>,
[src]
H: Borrow<Handle>,
Returns true if this Handle
was created by ObjectPool
, and has not been
freed yet.
fn free<H>(&mut self, handle: H) -> Option<T> where
H: Borrow<Handle>,
[src]
H: Borrow<Handle>,
Recycles the value with name Handle
.
fn free_if<P>(&mut self, predicate: P) -> FreeIter<T, P> where
P: FnMut(&T) -> bool,
[src]
P: FnMut(&T) -> bool,
Remove all objects matching with predicate
from pool incrementally.
fn len(&self) -> usize
[src]
Returns the total number of alive handle in this ObjectPool
.
fn iter(&self) -> HandleIter
[src]
Returns an iterator over the ObjectPool
.