Skip to content

Commit

Permalink
add bitmap
Browse files Browse the repository at this point in the history
  • Loading branch information
tickbh committed May 30, 2024
1 parent e848e45 commit 3ca0893
Show file tree
Hide file tree
Showing 3 changed files with 411 additions and 26 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ version = "0.1.2"
edition = "2021"
authors = ["tickbh <[email protected]>"]
description = "about algorithm data structure, now has lru/lru-k/lfu/slab/rbtree, 关于算法常用的数据结构"
repository = "https://github.com/tickbh/algorithm"
repository = "https://github.com/tickbh/algorithm-rs"
license = "Apache-2.0"
keywords = ["algorithm", "lru", "lfu", "lru-k", "slab"]

Expand Down
25 changes: 16 additions & 9 deletions examples/map_bitmap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,21 @@
use algorithm::BitMap;

fn main() {
// let mut map = BitMap::new(10240);
// map.add_many(&vec![1, 2, 3, 4, 10]);
// assert!(map.contains(&1));
// assert!(!map.contains(&5));
// assert!(map.contains(&10));
// map.add_range(7, 16);
// assert!(!map.contains(&6));
// assert!(map.contains(&7));
// assert!(map.contains(&16));
// assert!(!map.contains(&17));

let mut map = BitMap::new(10240);
map.add_many(&vec![1, 2, 3, 4, 10]);
assert!(map.contains(&1));
assert!(!map.contains(&5));
assert!(map.contains(&10));
map.add_range(7, 16);
assert!(!map.contains(&6));
assert!(map.contains(&7));
assert!(map.contains(&16));
assert!(!map.contains(&17));
map.add(7);
map.add_range(9, 12);
map.add_many(&vec![20, 100, 300]);
println!("value = {:?}", map.iter().collect::<Vec<_>>());
assert!(map.iter().collect::<Vec<_>>() == vec![7, 9, 10, 11, 12, 20, 100, 300]);
}
Loading

0 comments on commit 3ca0893

Please sign in to comment.