Open npasserini opened 8 years ago
Hi @npasserini Using TreeMap instead of HashMap only needs a WollokComparator already done (doesn't need wollokHash).
Still TreeMaps requires that keys are sortable, which could be not true for several objects. Maybe we need a more profound discussion about the didactic implications of this:
Both maps make those decissions thinking about performance. Also for dictionaries the overwhelming most common cases are that simple objects sush as strings are used as keys, so those problems are uncommon. But sets of user defined objects are common.
So maybe I can rethink my initial idea. I mean, if we could come up with a dictionary implementation that is slower but avoids us to teach the student about hashcodes or ordering... could that be a trade off we are willing to do?
More elegant is that all this concerns are only necessary for objects that redefine equals but not hashCode. So a super hancy implementation of a wollok set (map) could use a fast implementation while there are only "good" elements (keys), and resort to a slower implementation when it is needed to support objects that redefine equals but not hashCode.
Still TreeMaps requires that keys are sortable, which could be not true for several objects. Maybe we need a more profound discussion about the didactic implications of this:
@npasserini :+1:
So we can avoid sequential key serching like: