Some more timeline helpers

This commit is contained in:
Jeremy Penner 2013-03-18 22:06:37 -04:00
parent 7ca348442d
commit eaedaee31a

View file

@ -7,11 +7,16 @@
(let [queue (or (tln clock) [])] (let [queue (or (tln clock) [])]
(assoc tln clock (conj queue val)))) (assoc tln clock (conj queue val))))
(defn timeline-after [tln clock] (defn- timeline-strip [tln clock fnget fncmpzero]
(if-let [kvFirst (first tln)] (if-let [kv (fnget tln)]
(let [clockFirst (kvFirst 0)] (let [clockEnd (kv 0)]
(if (>= (.compare (.comp tln) clock clockFirst) 0) (if (fncmpzero (.compare (.comp tln) clock clockEnd) 0)
(recur (dissoc tln clockFirst) clock) (recur (dissoc tln clockEnd) clock fnget fncmpzero)
tln)) tln))
tln)) tln))
(defn timeline-after [tln clock] (timeline-strip tln clock first >=))
(defn timeline-before [tln clock] (timeline-strip tln clock last <=))
(defn timeline-last-value [tln]
(last (second (last tln))))