[][src]Trait indexed::Indexed

pub unsafe trait Indexed: Sized {
    unsafe fn get_index(&self) -> usize;
unsafe fn set_index(&mut self, index: usize); fn chunk_len() -> ChunkLen { ... }
fn null() -> usize { ... }
fn pool(&self) -> &Pool<Self> { ... }
unsafe fn pool_mut(&self) -> &mut Pool<Self> { ... }
fn pool_non_null(&self) -> NonNull<Pool<Self>> { ... }
fn pool_push(&self, value: Self) { ... }
unsafe fn pool_write(&self, index: usize, value: Self) { ... }
fn pool_reserve(&self, additional: usize) { ... } }

Type of elements in the Pool must implement this trait. Typically some integer field in the type must devote to storing the index in the pool, and it is not necessarily usize. For example, an index can be stored in u32 if 4194304K is enough for anybody.

Required methods

unsafe fn get_index(&self) -> usize

Gets the element's index in the pool.

unsafe fn set_index(&mut self, index: usize)

Sets the element's index in the pool. The library user is not expected to call it directly.

Loading content...

Provided methods

fn chunk_len() -> ChunkLen

Sets the underlying chunk size. The default is 256, and can be overrided by those values defined in ChunkLen.

fn null() -> usize

Defines which index value is for null. If the underlying storage for index is smaller than usize's size, the library user should override this method and pick a smaller value, e.g !0_u32 for index stored in u32. Note that it is for convenience only, and the library will not do any index check against null().

fn pool(&self) -> &Pool<Self>

Obtains reference of its pool.

unsafe fn pool_mut(&self) -> &mut Pool<Self>

Obtains mutable reference of its pool.

fn pool_non_null(&self) -> NonNull<Pool<Self>>

Obtains non null pointer of its pool.

fn pool_push(&self, value: Self)

Appends an element to the back of its pool.

unsafe fn pool_write(&self, index: usize, value: Self)

Overwrites a new value into its pool at given index without reading or dropping the old value.

fn pool_reserve(&self, additional: usize)

Reserves capacity for at least additional more elements to be inserted in the given Pool. The collection may reserve more space because the increasing size must be multiple of underlying chunk_len(). After calling reserve, capacity will be greater than or equal to self.pool().new_index() + additional. Does nothing if capacity is already sufficient.

Loading content...

Implementors

Loading content...