Skip to content

Commit

Permalink
add certified btree set, add get_random 1
Browse files Browse the repository at this point in the history
  • Loading branch information
seniorjoinu committed Apr 6, 2023
1 parent 22923a8 commit 3e20140
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "ic-stable-memory"
version = "0.4.3"
version = "0.4.4"
authors = ["Александр Втюрин <[email protected]>"]
edition = "2021"
description = "Internet Computer's stable memory collections and tools"
Expand All @@ -24,7 +24,7 @@ ic-stable-memory-derive = "0.4.2"
[dev-dependencies]
rand = "0.8.5"
ic-cdk-macros = "0.6.8"
candid_derive = "0.5.0"
candid_derive = "0.6.0"
ic-certified-map = "0.3.2"
serde_test = "1.0.152"

Expand Down
9 changes: 6 additions & 3 deletions src/collections/btree_map/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1742,8 +1742,10 @@ impl LeveledList {
match self {
LeveledList::None => {}
LeveledList::Some((v, _)) => {
if let Ok(idx) = v[level].binary_search(&ptr) {
v[level].remove(idx);
if let Some(level_list) = v.get_mut(level) {
if let Ok(idx) = level_list.binary_search(&ptr) {
level_list.remove(idx);
}
}
}
}
Expand All @@ -1753,7 +1755,8 @@ impl LeveledList {
match self {
LeveledList::None => unreachable!(),
LeveledList::Some((v, max_level)) => {
let mut ptr = v[*max_level].pop();
let level_list = v.get_mut(*max_level)?;
let mut ptr = level_list.pop();

while ptr.is_none() {
if *max_level == 0 {
Expand Down

0 comments on commit 3e20140

Please sign in to comment.