Trait indexed::Indexed

source ·
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) { ... }
}
Expand description

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

Gets the element’s index in the pool.

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

Provided Methods

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

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().

Obtains reference of its pool.

Obtains mutable reference of its pool.

Obtains non null pointer of its pool.

Appends an element to the back of its pool.

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

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.

Implementors