Permalink
Browse files

Fix metadata handling.

On Clojure 1.3 you can't have a deftype field with __ in it (so renamed __meta to _meta).
Added _meta argument into all constructor calls where it was missing.
  • Loading branch information...
1 parent af7b408 commit ad1bfcab9d2d7c728a9631174d553629c702b083 @seancorfield seancorfield committed Sep 11, 2011
Showing with 13 additions and 10 deletions.
  1. +13 −10 src/main/clojure/clojure/data/priority_map.clj
@@ -161,7 +161,7 @@ to Clojure's assortment of built-in maps (hash-map and sorted-map).
; as well as a hash map that maps items to priorities (item->priority)
; Priority maps may also have metadata
-(deftype PersistentPriorityMap [priority->set-of-items item->priority __meta]
+(deftype PersistentPriorityMap [priority->set-of-items item->priority _meta]
Object
(toString [this] (str (.seq this)))
@@ -188,19 +188,22 @@ to Clojure's assortment of built-in maps (hash-map and sorted-map).
(PersistentPriorityMap.
(assoc (dissoc priority->set-of-items current-priority)
priority (conj (get priority->set-of-items priority #{}) item))
- (assoc item->priority item priority))
+ (assoc item->priority item priority)
+ _meta)
;Subcase 3 - there were many items associated with the item's original priority,
;so remove it from the old set and conj it onto the new one.
(PersistentPriorityMap.
(assoc priority->set-of-items
current-priority (disj (get priority->set-of-items current-priority) item)
priority (conj (get priority->set-of-items priority #{}) item))
- (assoc item->priority item priority)))))
+ (assoc item->priority item priority)
+ _meta))))
; Case 2: Item is new to the priority map, so just add it.
(PersistentPriorityMap.
(assoc priority->set-of-items
priority (conj (get priority->set-of-items priority #{}) item))
- (assoc item->priority item priority)))))
+ (assoc item->priority item priority)
+ _meta))))
(empty [this] pm-empty)
@@ -236,11 +239,11 @@ to Clojure's assortment of built-in maps (hash-map and sorted-map).
(if (= (count item-set) 1)
;;If it is the only item with this priority, remove that priority's set completely
(PersistentPriorityMap. (dissoc priority->set-of-items priority)
- (dissoc item->priority item))
+ (dissoc item->priority item) _meta)
;;Otherwise, just remove the item from the priority's set.
(PersistentPriorityMap.
(assoc priority->set-of-items priority (disj item-set item)),
- (dissoc item->priority item)))))))
+ (dissoc item->priority item) _meta))))))
java.io.Serializable ;Serialization comes for free with the other things implemented
clojure.lang.MapEquivalence
@@ -273,11 +276,11 @@ to Clojure's assortment of built-in maps (hash-map and sorted-map).
;If the first item is the only item with its priority, remove that priority's set completely
(PersistentPriorityMap.
(dissoc priority->set-of-items priority)
- (dissoc item->priority item))
+ (dissoc item->priority item) _meta)
;Otherwise, just remove the item from the priority's set.
(PersistentPriorityMap.
(assoc priority->set-of-items priority (disj item-set item)),
- (dissoc item->priority item))))))
+ (dissoc item->priority item) _meta)))))
clojure.lang.IFn
;makes priority map usable as a function
@@ -286,7 +289,7 @@ to Clojure's assortment of built-in maps (hash-map and sorted-map).
clojure.lang.IObj
;adds metadata support
- (meta [this] __meta)
+ (meta [this] _meta)
(withMeta [this m] (PersistentPriorityMap. priority->set-of-items item->priority m))
clojure.lang.Reversible
@@ -306,7 +309,7 @@ to Clojure's assortment of built-in maps (hash-map and sorted-map).
;; (if ascending (seq this) (rseq this))))
(def ^:private pm-empty (PersistentPriorityMap. (sorted-map) {} {}))
-(defn- pm-empty-by [comparator] (PersistentPriorityMap. (sorted-map-by comparator) {}))
+(defn- pm-empty-by [comparator] (PersistentPriorityMap. (sorted-map-by comparator) {} {}))
; The main way to build priority maps
(defn priority-map

0 comments on commit ad1bfca

Please sign in to comment.