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) [])]
(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)
(defn- timeline-strip [tln clock fnget fncmpzero]
(if-let [kv (fnget tln)]
(let [clockEnd (kv 0)]
(if (fncmpzero (.compare (.comp tln) clock clockEnd) 0)
(recur (dissoc tln clockEnd) clock fnget fncmpzero)
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))))