Crates.io | xsparseset |
lib.rs | xsparseset |
version | 0.2.5 |
source | src |
created_at | 2021-08-23 09:05:33.021739 |
updated_at | 2022-10-10 09:19:51.369144 |
description | A rust sparse set |
homepage | |
repository | https://github.com/xstater/xsparseset/ |
max_upload_size | |
id | 441053 |
size | 22,839 |
sparse set is a data-structure with fast iteration and getting data from sparse ID
Sparse set has 2 arrays,the sparse array 'S' and dense array 'D'. The 'S' and 'D' array must satisfy 2 rules :
S[ID] == index
D[index] = ID
Because we need store data and entity ID. XSparseSet has 3 arrays , "indices" "entities" and "data".
let mut sparse_set = SparseSet::new();
sparse_set.add(4,'c');
sparse_set.add(7,'a');
assert_eq!(sparse_set.get(4),Some(&'c'));
assert_eq!(sparse_set.get(5),None);