I have compared my imlementation with the Internet, https://gist.github.com/supki/3881116,
It seems that mine is mostly better. Particularly, I have better times (both shorter and using Map.withDefault()), singletone, combined, makeOrderedLeafList (ok, makeOrderedLeafList and combine on extra insertSorted function), decode and codeBits.
Our until[A]() and createTreeCode totally match. quickEncode also identical except mine is more optimal -- it evaluates the table only once while his builds the table for every character.
I assume that texts like "aaa" or "" cannot be coded since first means that code tree is only Leaf(a, 3) and you have left/right for 1/0 whereas "" cannot even produce the code tree. I failed to understand the purpose of merge and how does it make the conding efficient.
No comments:
Post a Comment