Details
-
Type:
Defect
-
Status:
Closed
-
Priority:
Minor
-
Resolution: Declined
-
Affects Version/s: Release 1.2
-
Fix Version/s: None
-
Component/s: None
-
Labels:None
-
Environment:Ubuntu 10.04
Description
(def _sortedset (set (list 1,3,2))) (println _sortedset) (println (class _sortedset))
This code output is:
>> #{1 2 3}
>> clojure.lang.PersistentHashSet
As you can see set function create hash-set, but already sorted.
The hash set that you're creating only seems sorted. That is, while the ordering of a set is not guaranteed, it's a perfectly valid set if it is. The ordering in this case is due to implementation details guided by the fact that you happen to be inserting values of the same type whose hash values are ordered. If you make a change to one of the values then you could see a change:
(set (list 1 3.0 2))
;=> #{3.0 1 2)