Repairing previous unusual commit.

This commit is contained in:
paladin 2026-09-29 10:42:04 +01:00
parent d45e9bd270
commit 6b521cb59f

View file

@ -263,13 +263,35 @@ impl<E: TableEntry> DisplacementSet<E> {
}
}
}
}
pub fn new() -> DisplacementSet<E> {
pub fn get<K>(&mut self, index: K) -> Option<&E>
where
E: Equivalent<K>,
K: Hashes,
{
if self.map.len() == 0 {
return None;
}
let location = index.hashed() as usize % self.map.len();
let home = &self.map[location];
if home.entry.matches(&index) {
Some(&home.entry)
} else {
for i in 1..home.displacement as usize {
let neighbour = &self.map[(location + i) % self.map.len()];
if neighbour.entry.matches(&index) {
return Some(&neighbour.entry);
}
}
None
}
}
pub fn new() -> DisplacementSet<E> {
DisplacementSet {
map: Vec::new(),
map_count: 0,
map_bounds: (0..0).into(),
}
}
}
#[derive(Clone)]
@ -354,12 +376,6 @@ impl<E: Hashes + PartialEq> Equivalent<E> for SetEntry<E> {
}
}
impl<K, E: Hashes + PartialEq + Equivalent<K>> Equivalent<K> for SetEntry<E> {
fn matches(&self, other: &K) -> bool {
self.0.unwrap().matches(other)
}
}
impl<E: Hashes + PartialEq> Set<E> {
pub fn resize(&mut self, len: usize) {
self.0.resize(len)