On Mon, Dec 28, 2015 at 11:47 AM, Adam J. Shook <[email protected]> wrote:
> Hello all, > > Any suggestions for using a Map Lexicoder (or implementing one)? I am > currently using a new ListLexicoder(new PairLexicoder(some lexicoder, some > lexicoder), which is working for single maps. However, when one of the > lexicoders in the Pair is itself a Map (and therefore another > ListLexicoder(PairLexicoder)), an exception is being thrown because > ArrayList is not Comparable. > Since maps do not have a well defined order of keys and values, comparison is tricky. The purpose of Lexicoders is encode things in such a way that the lexicographical comparison of the serialized data is possible. With a hashmap if I add the same data in the same order to two different hash map instances, its possible that when iterating over those maps I could see the data in different orders. This could lead to two maps constructed in the same way at different times (like different JVMs with different implementations of HashMap) generating different data that compare as different. Ideally comparison of the two would yield equality. Something like LinkedHashMap does not have this problem for the same insertion order. If you want things to be comparable regardless of insertion order (which I think is more intuitive), then SortedMap seems like it would be a good candidate. So maybe a SortedMapLexicoder would be a better thing to offer? > Regards, > --Adam >
