[−][src]Struct ika::Pool
Let's go swimming!
Implementations
impl<T> Pool<T>
[src]
pub unsafe fn spawn_unchecked(&mut self) -> &mut T
[src]
Instantiate an object.
Undefined behavior if self.is_empty()
.
Object may have weird, possibly uninitialized, data.
pub fn spawn(&mut self) -> Option<&mut T>
[src]
Instantiate an object.
Will return None if self.is_empty()
.
Object may have weird, possibly uninitialized, data.
pub fn spawn_exact(&mut self, count: usize) -> Vec<&mut T>
[src]
Instantiate exactly count
objects.
If count > self.available()
, the resulting vector will be empty.
Object may have weird, possibly uninitialized, data.
pub fn spawn_some(&mut self, count: usize) -> Vec<&mut T>
[src]
Instantiate some objects.
If count > self.available()
, the resulting vector will have a length < count, and may be empty.
Object may have weird, possibly uninitialized, data.
pub fn reclaim<F: FnMut(&T) -> bool>(&mut self, kill_fn: F)
[src]
Kill objects in the pool based on kill_fn
.
If kill_fn
returns true, the object will be recycled.
Preserves ordering of the pool.
pub fn reclaim_unstable<F: FnMut(&T) -> bool>(&mut self, kill_fn: F)
[src]
Kill objects in the pool based on kill_fn
.
If kill_fn
returns true, the object will be recycled.
Doesn't necessarity preserve ordering of the pool.
pub fn attach(&mut self, at: usize, obj: T)
[src]
Move an object into the pool. Will resize the pool.
pub fn detach(&mut self, at: usize) -> T
[src]
Move an object out of the pool by index.
Will resize the pool.
Panics if index is out of bounds.
pub fn get(&self, at: usize) -> Option<&T>
[src]
pub fn get_mut(&mut self, at: usize) -> Option<&mut T>
[src]
pub fn iter(&self) -> Iter<T>ⓘ
[src]
pub fn iter_mut(&mut self) -> IterMut<T>ⓘ
[src]
pub fn sort_the_dead(&mut self)
[src]
Sort pointers to available objects for better cache locality.
pub fn is_empty(&self) -> bool
[src]
Returns whether there are available objects in the pool or not.
pub fn len(&self) -> usize
[src]
Number of objects in use in the pool.
pub fn available(&self) -> usize
[src]
Number of free objects in the pool.
pub fn capacity(&self) -> usize
[src]
Number of total objects in the pool.
impl<T: Default> Pool<T>
[src]
pub fn new(size: usize) -> Self
[src]
Create a new pool with a starting size of size
.
Objects will be initialized with T::default()
pub fn please_spawn(&mut self) -> &mut T
[src]
Please instantiate an object.
Will resize the pool if self.is_empty()
.
Intializes new object with T::default()
.
pub fn please_spawn_some(&mut self, count: usize) -> Vec<&mut T>
[src]
Instantiate exactly count
objects.
If count > self.available()
, the pool will be resized to account for the difference.
Intializes new objects with T::default()
.
Trait Implementations
impl<T: Clone> Clone for Pool<T>
[src]
impl<T: Debug> Debug for Pool<T>
[src]
impl<T: Default> Default for Pool<T>
[src]
impl<T: Eq> Eq for Pool<T>
[src]
impl<'a, T> IntoIterator for &'a Pool<T>
[src]
type 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]
impl<'a, T> IntoIterator for &'a mut Pool<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]
impl<T: PartialEq> PartialEq<Pool<T>> for Pool<T>
[src]
impl<T> StructuralEq for Pool<T>
[src]
Auto Trait Implementations
impl<T> RefUnwindSafe for Pool<T> where
T: RefUnwindSafe,
T: RefUnwindSafe,
impl<T> Send for Pool<T> where
T: Send,
T: Send,
impl<T> Sync for Pool<T> where
T: Sync,
T: Sync,
impl<T> Unpin for Pool<T> where
T: Unpin,
T: Unpin,
impl<T> UnwindSafe for Pool<T> where
T: UnwindSafe,
T: UnwindSafe,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,