minhash_rs/
minhash_array.rs1use core::ops::{Index, IndexMut};
2
3use crate::prelude::*;
4
5#[repr(transparent)]
6#[derive(Debug, Clone, Copy, PartialEq, Eq)]
7pub struct MinHashArray<Word, const PERMUTATIONS: usize, const N: usize> {
8 counters: [MinHash<Word, PERMUTATIONS>; N],
9}
10
11impl<Word: Maximal, const PERMUTATIONS: usize, const N: usize> Default
12 for MinHashArray<Word, PERMUTATIONS, N>
13{
14 fn default() -> Self {
15 Self::new()
16 }
17}
18
19impl<Word: Maximal, const PERMUTATIONS: usize, const N: usize> MinHashArray<Word, PERMUTATIONS, N> {
20 pub fn new() -> Self {
21 Self {
22 counters: [MinHash::new(); N],
23 }
24 }
25}
26
27impl<W: Maximal, const PERMUTATIONS: usize, const N: usize> Index<usize>
29 for MinHashArray<W, PERMUTATIONS, N>
30{
31 type Output = MinHash<W, PERMUTATIONS>;
32
33 fn index(&self, index: usize) -> &Self::Output {
34 &self.counters[index]
35 }
36}
37
38impl<W: Maximal, const PERMUTATIONS: usize, const N: usize> IndexMut<usize>
39 for MinHashArray<W, PERMUTATIONS, N>
40{
41 fn index_mut(&mut self, index: usize) -> &mut Self::Output {
42 &mut self.counters[index]
43 }
44}