Skip to content

Added Tombstones #12

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 7 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Compiled files
*.o
*.so
*.rlib
*.dll

# Executables
*.exe

# Generated by Cargo
/target/
Cargo.lock

2 changes: 0 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -10,8 +10,6 @@ description = "A hash table with consistent order and fast iteration."
[lib]
bench = false

[dependencies]

[dev-dependencies]
itertools = "0.5.1"
rand = "0.3"
33 changes: 33 additions & 0 deletions benches/bench.rs
Original file line number Diff line number Diff line change
@@ -610,3 +610,36 @@ fn retain_many_ordermap_100_000(b: &mut Bencher) {
map
});
}

#[bench]
fn remove_index_tombstones_many_ordermap_100_000(b: &mut Bencher) {
let mut map = OMAP_100K.clone();
map.retain(|k, _| *k % 7 == 0);

b.iter(|| {
let mut map = map.clone();
map.remove_index_tombstones()
});
}

#[bench]
fn remove_index_tombstones_half_ordermap_100_000(b: &mut Bencher) {
let mut map = OMAP_100K.clone();
map.retain(|k, _| *k % 2 == 0);

b.iter(|| {
let mut map = map.clone();
map.remove_index_tombstones()
});
}

#[bench]
fn remove_index_tombstones_some_ordermap_100_000(b: &mut Bencher) {
let mut map = OMAP_100K.clone();
map.retain(|k, _| *k % 100 == 0);

b.iter(|| {
let mut map = map.clone();
map.remove_index_tombstones()
});
}
1,942 changes: 1,469 additions & 473 deletions src/lib.rs

Large diffs are not rendered by default.

8 changes: 0 additions & 8 deletions src/util.rs
Original file line number Diff line number Diff line change
@@ -1,16 +1,8 @@

use std::iter::Enumerate;
use std::mem::size_of;

pub fn second<A, B>(t: (A, B)) -> B { t.1 }
pub fn enumerate<I>(iterable: I) -> Enumerate<I::IntoIter>
where I: IntoIterator
{
iterable.into_iter().enumerate()
}

/// return the number of steps from a to b
pub fn ptrdistance<T>(a: *const T, b: *const T) -> usize {
debug_assert!(a as usize <= b as usize);
(b as usize - a as usize) / size_of::<T>()
}
7 changes: 3 additions & 4 deletions tests/quick.rs
Original file line number Diff line number Diff line change
@@ -123,8 +123,8 @@ impl<K, V> Arbitrary for Op<K, V>
}

fn do_ops<K, V>(ops: &[Op<K, V>], a: &mut OrderMap<K, V>, b: &mut HashMap<K, V>)
where K: Hash + Eq + Clone,
V: Clone,
where K: Hash + Eq + Clone + Debug,
V: Clone + Debug,
{
for op in ops {
match *op {
@@ -151,7 +151,7 @@ fn do_ops<K, V>(ops: &[Op<K, V>], a: &mut OrderMap<K, V>, b: &mut HashMap<K, V>)
}
}
}
//println!("{:?}", a);
assert_eq!(a.len(), b.len(), "last operation was {:?}", op);
}
}

@@ -200,7 +200,6 @@ quickcheck! {
assert!(map.contains_key(key));
}
true

}

// Check that retain visits each key exactly once