xsparseset

Crates.ioxsparseset
lib.rsxsparseset
version0.2.5
sourcesrc
created_at2021-08-23 09:05:33.021739
updated_at2022-10-10 09:19:51.369144
descriptionA rust sparse set
homepage
repositoryhttps://github.com/xstater/xsparseset/
max_upload_size
id441053
size22,839
xstater (xstater)

documentation

https://docs.rs/xsparseset/

README

XSparseSet

sparse set is a data-structure with fast iteration and getting data from sparse ID

sparse set

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
    These 2 rules make us get data from ID quickly and we can store all data densely.

Details

Because we need store data and entity ID. XSparseSet has 3 arrays , "indices" "entities" and "data".

  • indices : the sparse array
  • entities : the dense array
  • data : the dense array

Examples

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);
Commit count: 48

cargo fmt