#![doc(html_root_url = "https://docs.rs/emap/0.0.11")]
#![deny(warnings)]
#![warn(clippy::all, clippy::pedantic, clippy::nursery, clippy::cargo)]
#![allow(clippy::multiple_inherent_impl)]
#![allow(clippy::multiple_crate_versions)]
mod clone;
mod ctors;
mod debug;
mod index;
mod iterators;
mod keys;
mod map;
mod next_key;
#[cfg(feature = "serde")]
mod serialization;
mod values;
use std::alloc::Layout;
use std::marker::PhantomData;
pub struct Map<V> {
max: usize,
head: *mut Option<V>,
layout: Layout,
#[cfg(debug_assertions)]
initialized: bool,
}
pub struct Iter<'a, V> {
max: usize,
pos: usize,
head: *mut Option<V>,
_marker: PhantomData<&'a V>,
}
pub struct IntoIter<V> {
max: usize,
pos: usize,
head: *mut Option<V>,
}
pub struct Values<'a, V> {
max: usize,
pos: usize,
head: *mut Option<V>,
_marker: PhantomData<&'a V>,
}
pub struct IntoValues<V> {
max: usize,
pos: usize,
head: *mut Option<V>,
}
pub struct Keys<V> {
max: usize,
pos: usize,
head: *mut Option<V>,
}
#[cfg(test)]
use std::time::Instant;
#[test]
fn perf() {
let cap = 256;
let mut m: Map<&str> = Map::with_capacity_none(cap);
let start = Instant::now();
for _ in 0..1000 {
m.clear();
for _ in 0..cap {
m.push("Hello, world!");
}
for i in 0..cap {
m.remove(i);
}
for (k, _) in m.into_iter() {
m.remove(k);
}
for i in 0..cap {
assert!(!m.contains_key(i));
}
}
let d = start.elapsed();
println!("Total time: {}", d.as_millis());
}