Hi, By default, maps are array-map for short map and hash map for larger one. That explains why the map seems sorted at the beginning.
Christian Le 5 août 2012 à 10:40, Evan Mezeske <emeze...@gmail.com> a écrit : > I know the sorted-map, but my question is : why the map is not 'ordered' when > size is larger than 32 ? > > Because a hash-map is never guaranteed to be sorted. In your case, it sounds > like Clojure is being smart and using a different implementation for small > maps (say, less than 32 elements) than it is using for larger maps. This is > probably because there's some clever optimization that can be done for very > small maps that becomes a pessimization as the map grows larger. The data > structure that's being used behind the scenes for small maps might *happen* > to have the property of being sorted, but if so, it is just an implementation > quirk and you can't rely on that fact in your code. Sorted order is simply > not part of the hash-map contract. The 32 element behind-the-scenes limit > might change tomorrow, after someone does an analysis and determines that > really, three different implementations should be used, one for up to 16 > elements, one for up to 128, and one for more. Who knows? > -- > You received this message because you are subscribed to the Google > Groups "Clojure" group. > To post to this group, send email to clojure@googlegroups.com > Note that posts from new members are moderated - please be patient with your > first post. > To unsubscribe from this group, send email to > clojure+unsubscr...@googlegroups.com > For more options, visit this group at > http://groups.google.com/group/clojure?hl=en -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en