···4545 pub fn process_element(&mut self, elem: T) {
4646 // We should switch to a treap (as per Knuth) to avoid the hash overhead, but FxHash
4747 // is still a lot faster than linear searching a Vec, even at small (1000) buffer sizes
4848- self.buf.remove(&elem);
4848+ // Round 0: if an element exists, remove it. Element is added back due to probability 1
4949+ // When buffer is full, remove half the elements
5050+ // Round 1: if an element exists, remove it. Element MAY be added back due to probability 0.5
5151+ if self.buf.get(&elem).is_some() {
5252+ self.buf.remove(&elem);
5353+ }
4954 if self.rng.gen_bool(self.probability) {
5055 self.buf.insert(elem);
5156 }