Struct chunky::Arena [−][src]
pub struct Arena<H: Handler> { /* fields omitted */ }
Stores items of a fixed (max) size consecutively in a collection of chunks
Methods
impl<H: Handler> Arena<H>
[src]
impl<H: Handler> Arena<H>
pub fn new(ident: Ident, chunk_size: usize, item_size: usize) -> Arena<H>
[src]
pub fn new(ident: Ident, chunk_size: usize, item_size: usize) -> Arena<H>
Create a new arena given a chunk group identifier, chunk size and (max) item size
pub fn len(&self) -> usize
[src]
pub fn len(&self) -> usize
Number of elements in the collection
pub fn is_empty(&self) -> bool
[src]
pub fn is_empty(&self) -> bool
Is the collection empty?
pub fn push(&mut self) -> (*mut u8, ArenaIndex)
[src]
pub fn push(&mut self) -> (*mut u8, ArenaIndex)
Allocate space for a new item, returns a pointer to where the new item can be written to and the index that the new item will have.
This is handled like this so items of heterogeneous types or sizes less than the fixed item size can be added to the collection.
pub fn pop_away(&mut self)
[src]
pub fn pop_away(&mut self)
Remove the last item from the end
pub unsafe fn swap_remove(&mut self, index: ArenaIndex) -> Option<*const u8>
[src]
pub unsafe fn swap_remove(&mut self, index: ArenaIndex) -> Option<*const u8>
Remove the item at index, by swapping it with the last item and then popping, returning the swapped in item (unless empty).
This is a O(1) way of removing an item if the order of items doesn't matter.
pub unsafe fn at(&self, index: ArenaIndex) -> *const u8
[src]
pub unsafe fn at(&self, index: ArenaIndex) -> *const u8
Get a pointer to the item at index
pub unsafe fn at_mut(&mut self, index: ArenaIndex) -> *mut u8
[src]
pub unsafe fn at_mut(&mut self, index: ArenaIndex) -> *mut u8
Get a mutable pointer to the item at index