SHARE
TWEET

Untitled

a guest Aug 18th, 2019 74 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. pub fn from_bytes_stream<I, H>(seq_iter: I, build_hasher: &H) -> Self
  2.     where
  3.         I: Iterator<Item=u8>,
  4.         H: BuildHasher,
  5. {
  6.     let mut dict = HashSet::new();
  7.     let mut hasher = build_hasher.build_hasher();
  8.  
  9.     for byte in seq_iter {
  10.         hasher.write_u8(byte);
  11.         let hash = hasher.finish() as i32;
  12.         if dict.insert(hash) {
  13.             hasher = build_hasher.build_hasher();
  14.         }
  15.     }
  16.  
  17.     let mut dict: Vec<_> = dict.iter().cloned().collect();
  18.     dict.sort();
  19.  
  20.     LZDict { entries: dict.iter().cloned().take(1000).collect() }
  21. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top