1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
use core::ops::{Index, IndexMut};

use crate::prelude::*;

#[repr(transparent)]
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub struct MinHashArray<Word, const PERMUTATIONS: usize, const N: usize> {
    counters: [MinHash<Word, PERMUTATIONS>; N],
}

impl<Word: Maximal, const PERMUTATIONS: usize, const N: usize> Default
    for MinHashArray<Word, PERMUTATIONS, N>
{
    fn default() -> Self {
        Self::new()
    }
}

impl<Word: Maximal, const PERMUTATIONS: usize, const N: usize> MinHashArray<Word, PERMUTATIONS, N> {
    pub fn new() -> Self {
        Self {
            counters: [MinHash::new(); N],
        }
    }
}

/// We also provide indexing for the MinHashArray.
impl<W: Maximal, const PERMUTATIONS: usize, const N: usize> Index<usize>
    for MinHashArray<W, PERMUTATIONS, N>
{
    type Output = MinHash<W, PERMUTATIONS>;

    fn index(&self, index: usize) -> &Self::Output {
        &self.counters[index]
    }
}

impl<W: Maximal, const PERMUTATIONS: usize, const N: usize> IndexMut<usize>
    for MinHashArray<W, PERMUTATIONS, N>
{
    fn index_mut(&mut self, index: usize) -> &mut Self::Output {
        &mut self.counters[index]
    }
}