(&self, rng: &mut R)
| 35 | } |
| 36 | |
| 37 | pub fn choose<R: Rng>(&self, rng: &mut R) -> Option<(&[u8], u8)> { |
| 38 | let index = match ENABLE_DICTIONARY_WEIGHTS { |
| 39 | true => self.weights.as_ref()?.sample(rng), |
| 40 | false => rng.gen_range(0..self.entries.len()), |
| 41 | }; |
| 42 | self.entries.iter().nth(index).map(|(_, item)| (item.value.as_slice(), item.strides)) |
| 43 | } |
| 44 | |
| 45 | pub fn is_empty(&self) -> bool { |
| 46 | self.entries.is_empty() || (ENABLE_DICTIONARY_WEIGHTS && self.weights.is_none()) |
no test coverage detected