Skip to content
Snippets Groups Projects
Commit 7d2162cc authored by Mathis "what could possibly go wrong" Randl's avatar Mathis "what could possibly go wrong" Randl
Browse files

fmt

parent 25cd1ae0
Branches
No related tags found
No related merge requests found
......@@ -14,6 +14,9 @@ where
}
}
pub trait DefaultApproximateCache<K, V> : ApproximateCache<K, V> where K : ApproxComparable {
fn from_capacity(cap : usize) -> Self;
}
\ No newline at end of file
pub trait DefaultApproximateCache<K, V>: ApproximateCache<K, V>
where
K: ApproxComparable,
{
fn from_capacity(cap: usize) -> Self;
}
......@@ -53,8 +53,12 @@ where
}
}
impl <K, V> DefaultApproximateCache<K, V> for FifoCache<K, V> where K : ApproxComparable, V : Clone {
fn from_capacity(cap : usize) -> FifoCache<K, V> {
impl<K, V> DefaultApproximateCache<K, V> for FifoCache<K, V>
where
K: ApproxComparable,
V: Clone,
{
fn from_capacity(cap: usize) -> FifoCache<K, V> {
FifoCache::new(cap)
}
}
......
......@@ -92,8 +92,12 @@ where
}
}
impl <K, V> DefaultApproximateCache<K, V> for LruCache<K, V> where K : ApproxComparable + Eq + Hash + Clone, V : Clone {
fn from_capacity(cap : usize) -> Self {
impl<K, V> DefaultApproximateCache<K, V> for LruCache<K, V>
where
K: ApproxComparable + Eq + Hash + Clone,
V: Clone,
{
fn from_capacity(cap: usize) -> Self {
LruCache::new(cap)
}
}
......
......@@ -40,12 +40,11 @@ impl<C> LshCache<C> {
}
}
impl<K, V, C> ApproximateCache<K, V> for LshCache<C>
where
V: Clone,
K: ApproxComparable + AsRef<[f32]>,
C : DefaultApproximateCache<K, V>
C: DefaultApproximateCache<K, V>,
{
/// Find a value by key, mutably accessing the bucket for potential reordering.
fn find(&mut self, target: &K) -> Option<V> {
......@@ -194,8 +193,7 @@ mod tests {
#[test]
fn test_lsh_lru_cache_basic() {
let mut cache =
LshLruCache::new(NUM_HASH, DIM, BUCKET_CAP, Some(99));
let mut cache = LshLruCache::new(NUM_HASH, DIM, BUCKET_CAP, Some(99));
let k1 = TestVecF32(vec![0.1; DIM]);
let k2 = TestVecF32(vec![-0.1; DIM]);
......
......@@ -2,4 +2,4 @@ mod hasher;
mod lsh_cache;
pub use lsh_cache::LshCache;
pub use lsh_cache::LshFifoCache;
pub use lsh_cache::LshLruCache;
\ No newline at end of file
pub use lsh_cache::LshLruCache;
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment