Struct index_pool::IndexPool [] [src]

pub struct IndexPool { /* fields omitted */ }

A pool which manages allocation of unique indices. Acts like a psuedo-memory allocator.

Methods

impl IndexPool
[src]

[src]

Constructs an empty IndexPool. Indices will start at 0.

[src]

Constructs an empty IndexPool. index will be the first index returned from new_id. You can logically think of this as either specifying a base index for the pool, or pre-allocating the [0..index) range. This datastructure does not care which is your usecase, and neither has any kind of performance penalty, except that in_use() will include the [0..index) range.

[src]

Allocates a new index for use. This is guaranteed to not be any index which has previously been returned from new_id but has not yet been passed to return_id.

[src]

Attempts to allocate a specific index

[src]

Gives an Id back to the pool so that it may be handed out again. Returns Err if the Id was not in use at the time. Whether ignoring such an error is okay is up to your own usecase.

[src]

Returns an upper bound on the number of IDs which have been allocated, specifically the highest numbered ID in use + 1. Useful if you're going to e.g. create a Vec which has room for all of your IDs.

[src]

Returns the number of currently in-use indices

[src]

Checks if a specific index is currently free

Important traits for IndexIter<'a>
[src]

Returns an iterator over all indices which are in use

Important traits for IndexAfterIter<'a>
[src]

[src]

Trait Implementations

impl Debug for IndexPool
[src]

[src]

Formats the value using the given formatter. Read more

impl Default for IndexPool
[src]

[src]

Constructs an empty IndexPool. Indices will start at 0.

Auto Trait Implementations

impl Send for IndexPool

impl Sync for IndexPool