Nothing Special   »   [go: up one dir, main page]

Skip to content

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

License

Notifications You must be signed in to change notification settings

Connicpu/index-pool

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

25 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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"]);
}

About

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

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages