| License | BSD-3-Clause |
|---|---|
| Safe Haskell | Safe-Inferred |
| Language | Haskell2010 |
Swarm.Util.OccurrenceEncoder
Description
Useful for compressing the representation of a structure that has many repeating elements for transmission (e.g. over the network).
Synopsis
- runEncoder :: (Traversable t, Ord b) => t b -> (t Int, [b])
Documentation
runEncoder :: (Traversable t, Ord b) => t b -> (t Int, [b]) Source #
Given a data structure that may have many repeating "complex" elements, will store the "complex" element representation in an array so that the structure's elements can be replaced with simple indices into that array.
The first encountered element is assigned index 0, and the next novel element encountered gets index 1, and so on.