Skip to content

Instantly share code, notes, and snippets.

@diegoeche
Created October 31, 2013 14:22
Show Gist options
  • Save diegoeche/7250637 to your computer and use it in GitHub Desktop.
Save diegoeche/7250637 to your computer and use it in GitHub Desktop.
def compress!
r_i = 0.0
c = Cursor.new(self.samples)
while ~c != nil && ~c.next != nil
r_i = (~c).rank + (~c.next).value + (~c.next).delta
if r_i <= @invariant.upper_bound(r_i, n)
removed = ~c.next
(~c).value = removed.value
(~c).delta = removed.delta
c.remove!
end
r_i += (~c).rank
c = c.next
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment