Advertisement
Guest User

Untitled

a guest
Aug 18th, 2019
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.55 KB | None | 0 0
  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. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement