# HG changeset patch # User Paul Boddie # Date 1421953986 -3600 # Node ID 3feba2b55cfcf838e76934238996764f20e2f890 # Parent 1fe444f390cd9e5558420c901ef002517fa8c214 Added some explanatory comments. diff -r 1fe444f390cd -r 3feba2b55cfc imiptools/period.py --- a/imiptools/period.py Thu Jan 22 18:41:32 2015 +0100 +++ b/imiptools/period.py Thu Jan 22 20:13:06 2015 +0100 @@ -148,11 +148,15 @@ for point, (starting, ending) in get_scale(l): # Discard all active events ending at or before this start time. + # Free up the position in the active list. for t in ending: i = active.index(t) active[i] = None + # For each event starting at the current point, fill any newly-vacated + # position or add to the end of the active list. + for t in starting: try: i = active.index(None) @@ -160,6 +164,8 @@ except ValueError: active.append(t) + # Discard vacant positions from the end of the active list. + while active and active[-1] is None: active.pop()