1#[derive(Debug, Clone, PartialEq)]
3pub struct DuplicateCluster {
4 pub id: usize,
6 pub indices: Vec<usize>,
8 pub representative: usize,
10}
11
12impl DuplicateCluster {
13 pub fn new(id: usize, representative: usize) -> Self {
15 Self {
16 id,
17 indices: vec![representative],
18 representative,
19 }
20 }
21
22 pub fn add(&mut self, index: usize) {
24 self.indices.push(index);
25 }
26
27 #[must_use]
29 pub fn len(&self) -> usize {
30 self.indices.len()
31 }
32
33 #[must_use]
35 pub fn is_empty(&self) -> bool {
36 self.indices.is_empty()
37 }
38
39 #[must_use]
41 pub fn is_duplicate(&self) -> bool {
42 self.len() > 1
43 }
44
45 #[must_use]
47 pub fn contains(&self, index: usize) -> bool {
48 self.indices.contains(&index)
49 }
50}