             [angelic.search.summary :as summary]            
             [angelic.search.summaries :as summaries]
             [angelic.search.function-sets :as fs])
-  (:import [java.util HashMap ArrayList]))
+  (:import [java.util HashMap ArrayList IdentityHashMap]))
 
 ;; A revampting of dash_astar_opt, to move subsumption relationships and caching
 ;; out into a separate class.  This is necessary to keep pessimistic and optimistic

  (if-let [left-sp (get-stub-output left-stub)]
    (make-pair-stub2 left-sp (right-stub-fn (output-set left-sp)))
    (let [ret (traits/reify-traits [summaries/or-summarizable (simple-stub nm (input-set left-stub))])]
      (connect-and-watch-stub! ret left-stub 
        (fn [lo]
          (connect-and-watch-stub-up! ret
            (make-pair-stub2 lo (right-stub-fn (output-set lo)))
            #(set-stub-output! ret %))))
      ret)))


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Used on stubs ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;; Just give output directly if subproblem is ready; return true if waiting
;; if up?, updates p if c does not produce immediate output.
(defn- connect-and-watch-stub! [p c up? f]
  (assert (instance? angelic.search.implicit.dash_astar.Stub c))
  (if-let [sp (get-stub-output c)]
    (f sp)
    (do (summaries/connect! p c)
        (add-watcher! c f)
        (when up? (summaries/summary-changed! p)))))

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Making stubs ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

