[0, 0]
.set(index, val)
is called, append a new record [current_snap_id, val]
to the history of the specified index.snap()
is called, increment the current_snap_id
and return the previous ID.get(index, snap_id)
is called, perform a binary search on the history of the specified index to find the record with the greatest snapshot ID that is less than or equal to snap_id
, and return the associated value.