Fleshing out the solution I outlined in a previous email, here's a
concrete implementation that lets you use maps as priorities.

(defn- make-id-generator []
  (let [i (atom 0),
        generate-unique-id (fn generate-unique-id [item] (swap! i inc))]
    (memoize generate-unique-id)))

(defn- make-map-comparator []
  (let [id (make-id-generator)]
    #(compare [(count %2) (id %2)] [(count %1) (id %1)])))

(def p (priority-map-by (make-map-comparator)))


[Note that this implementation keeps the memoization cache local to
the priority-map, so if your priority map goes out of scope, the
memoization cache should be garbage collectable]

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to [email protected]
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Reply via email to