pub fn finish(&mut self) -> Result<usize, io::Error> {
        let nm = self.elements.len() as u64 * self.m;

        // map hashes to [0, n_elements * M)
        let mut mapped: Vec<_> = self
            .elements
            .iter()
            .map(|e| map_to_range(self.filter.hash(e.as_slice()), nm))
            .collect();
        mapped.sort();

        // NOTE: bitcoin use VarInt here
        // write number of elements as varint
        let mut wrote = self.writer.write(&(mapped.len() as u64).to_le_bytes())?;

        // write out deltas of sorted values into a Golonb-Rice coded bit stream
        let mut writer = BitStreamWriter::new(self.writer);
        let mut last = 0;
        for data in mapped {
            wrote += self.filter.golomb_rice_encode(&mut writer, data - last)?;
            last = data;
        }
        wrote += writer.flush()?;
        Ok(wrote)
    }
/// write the filter to the wrapped writer
write the filter to the wrapped writer
write the filter to the wrapped writer
pub fn finish(&mut self) -> Result<usize, io::Error> {
        let nm = self.elements.len() as u64 * self.m;
        // map hashes to [0, n_elements * M)
        let mut mapped: Vec<_> = self
            .elements
            .iter()
            .map(|e| map_to_range(self.filter.hash(e.as_slice()), nm))
            .collect();
        mapped.sort();
        // NOTE: bitcoin use VarInt here
        // write number of elements as varint
        let mut wrote = self.writer.write(&(mapped.len() as u64).to_le_bytes())?;
        // write out deltas of sorted values into a Golonb-Rice coded bit stream
        let mut writer = BitStreamWriter::new(self.writer);
        let mut last = 0;
        for data in mapped {
            wrote += self.filter.golomb_rice_encode(&mut writer, data - last)?;
            last = data;
        }
        wrote += writer.flush()?;
        Ok(wrote)
    }
pub fn finish ( & mut self ) -> Result < usize , io :: Error > { let nm = self . elements . len ( ) as u64 * self . m ; // map hashes to [0, n_elements * M) let mut mapped : Vec < _ > = self . elements . iter ( ) . map ( | e | map_to_range ( self . filter . hash ( e . as_slice ( ) ) , nm ) ) . collect ( ) ; mapped . sort ( ) ; // NOTE: bitcoin use VarInt here // write number of elements as varint let mut wrote = self . writer . write ( & ( mapped . len ( ) as u64 ) . to_le_bytes ( ) ) ? ; // write out deltas of sorted values into a Golonb-Rice coded bit stream let mut writer = BitStreamWriter :: new ( self . writer ) ; let mut last = 0 ; for data in mapped { wrote += self . filter . golomb_rice_encode ( & mut writer , data - last ) ? ; last = data ; } wrote += writer . flush ( ) ? ; Ok ( wrote ) }
write the filter to the wrapped writer
write the filter to the wrapped writer
&mut self
&mut self