#index #pool #indices #datastructures

index-pool

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

11 stable releases

Uses old Rust 2015

1.0.11 May 10, 2018
1.0.10 May 9, 2018
1.0.7 Sep 11, 2017
1.0.2 Aug 25, 2017

#262 in Memory management

Download history 37/week @ 2023-01-25 23/week @ 2023-02-01 63/week @ 2023-02-08 85/week @ 2023-02-15 28/week @ 2023-02-22 27/week @ 2023-03-01 57/week @ 2023-03-08 77/week @ 2023-03-15 49/week @ 2023-03-22 9/week @ 2023-03-29 42/week @ 2023-04-05 49/week @ 2023-04-12 14/week @ 2023-04-19 40/week @ 2023-04-26 26/week @ 2023-05-03 52/week @ 2023-05-10

137 downloads per month
Used in conniecs

MIT license

11KB
234 lines

index-pool index-pool on crates.io Build Status Build status

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

[dependencies]
index-pool = "1.0"

Example

extern crate index_pool;
use index_pool::IndexPool;

fn main() {
    let mut pool = IndexPool::new();

    let a = pool.new_id();
    let b = pool.new_id();
    let c = pool.new_id();

    let mut data = vec![""; pool.maximum()];
    data[a] = "apple";
    data[b] = "banana";
    data[c] = "coconut";

    // Nevermind, no bananas
    pool.return_id(b).unwrap();

    let p = pool.new_id();
    data[p] = "pineapple";

    assert_eq!(data, vec!["apple", "pineapple", "coconut"]);
}

Dependencies

~10KB