4 # Instantiate a new Timeline
5 # +max_size+ is the maximum size to which the timeline should grow
8 def initialize(max_size)
13 # Push a value onto the Timeline
14 # +val+ is the value to push
16 # Implementation explanation:
17 # A performance optimization appears here to speed up the push time.
18 # In essence, the code does this:
22 # shift if size > @max_size
25 # But that's super slow due to the shift, so we resort to reverse! and pop
26 # which gives us a 2x speedup with 100 elements and a 6x speedup with 1000
30 if (size + 1) > @max_size
38 # Push a value onto the timeline
39 # +val+ is the value to push