From 805874a4c1b90774dad08277ffff1dde91409d19 Mon Sep 17 00:00:00 2001 From: paladin Date: Thu, 1 Oct 2026 09:09:41 +0100 Subject: [PATCH] Undo previous change and remove Sets implementation. --- src/lib.rs | 1 - src/map.rs | 64 ++++++------------------------------------------------ 2 files changed, 7 insertions(+), 58 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index c830934..c321a90 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,6 +1,5 @@ pub mod gc; pub mod map; - #[cfg(test)] mod tests { #[test] diff --git a/src/map.rs b/src/map.rs index e6a8d72..583a47d 100644 --- a/src/map.rs +++ b/src/map.rs @@ -33,6 +33,12 @@ pub trait Equivalent: Sized { fn matches(&self, other: &T) -> bool; } +impl Equivalent for T { + fn matches(&self, other: &T) -> bool { + self == other + } +} + pub trait Hashes { fn hashed(&self) -> Hashed; } @@ -341,60 +347,4 @@ impl Debug for Map { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { f.write_fmt(format_args!("Map")) // todo: debug and print the entire thing? } -} - -#[derive(PartialEq)] -pub struct SetEntry(Option); - -pub struct Set(DisplacementSet>); - -impl Hashes for SetEntry { - fn hashed(&self) -> Hashed { - todo!() - } -} - -impl TableEntry for SetEntry { - const VACANT: Self = SetEntry(None); - fn is_vacant(&self) -> bool { - self.0.is_none() - } -} - -impl Equivalent for SetEntry { - fn matches(&self, other: &E) -> bool { - self.0.as_ref().unwrap() == other - } -} - -impl Equivalent for SetEntry where K: Equivalent { - fn matches(&self, other: &K) -> bool { - other.matches(&self.0.as_ref().unwrap()) - } -} - -impl Set { - pub fn resize(&mut self, len: usize) { - self.0.resize(len) - } - pub fn set(&mut self, element: E) { - self.0.set(SetEntry(Some(element))); - } - pub fn remove(&mut self, element: E) { - self.0.remove(element); - } - pub fn get(&mut self, element: K) -> Option<&E> - where - E: Equivalent, - K: Hashes, - { - if let Some(ref entry) = self.0.get(element) { - Some(&entry.0.as_ref().unwrap()) - } else { - None - } - } - pub fn new() -> Set { - Set(DisplacementSet::new()) - } -} +} \ No newline at end of file