Get the latest tech news

Monoid-Augmented FIFOs, Deamortised


Paul Khuong's personal blog. Some Lisp, some optimisation, mathematical or computer.

Depending on the actual aggregation, it might not be beneficial to introduce branches around the suffix product update… but it’s nice to see how low we can go, especially for a common situation like a steady state where pushes and pops are roughly matched. We push by appending to the underlying windowed store, updating our state to take the new value into account, and calling the maintain method to incrementally recompute the excretion list’s suffix product. This is pretty complicated, so I tested the code by exhaustively enumerating all short push/pop sequences for the free (list append) monoid; see the bottom of the implementation file.

Get the Android app

Or read this on Hacker News

Read more on:

Photo of Monoid-Augmented

Monoid-Augmented

Photo of Augmented FIFOs

Augmented FIFOs