diff --git a/src/hottub/timeline.clj b/src/hottub/timeline.clj new file mode 100644 index 0000000..5fdf194 --- /dev/null +++ b/src/hottub/timeline.clj @@ -0,0 +1,17 @@ +(ns hottub.timeline) + +(defn timeline-create [& [fncomparison]] + (clojure.lang.PersistentTreeMap/create (or fncomparison #(- %1 %2)) nil)) + +(defn timeline-insert [tln clock val] + (let [queue (or (tln clock) [])] + (assoc tln clock (conj queue val)))) + +(defn timeline-after [tln clock] + (if-let [kvFirst (first tln)] + (let [clockFirst (kvFirst 0)] + (if (>= (.compare (.comp tln) clock clockFirst) 0) + (recur (dissoc tln clockFirst) clock) + tln)) + tln)) +