package octez-l2-libs
Install
dune-project
Dependency
Authors
Maintainers
Sources
sha256=55ea1fb8bb3273a7fc270ca8f650d45c56449665619482aad9bc12f3ea736b7e
sha512=fec850fc2d17d7490bbabd5147d62aad13b3aaed8774270f8a38ab419670ed03e0fd30cf8642a97984eca5c2446726fe590ad99c015f7ec50919dc7652f25053
doc/octez-l2-libs.smart-rollup/Octez_smart_rollup/Inbox/Skip_list/index.html
Module Inbox.Skip_listSource
A cell in the skip list carrying a given 'content and back pointers of type 'ptr.
val pp :
pp_ptr:(Format.formatter -> 'ptr -> unit) ->
pp_content:(Format.formatter -> 'content -> unit) ->
Format.formatter ->
('content, 'ptr) cell ->
unitval encoding :
'ptr Data_encoding.t ->
'content Data_encoding.t ->
('content, 'ptr) cell Data_encoding.tcontent cell is the content carried by the cell.
back_pointer cell i returns Some ptr if ptr is the i-th back pointer of cell. Returns None if the cell contains less than i + 1 back pointers.
back_pointers cell returns the back pointers of cell.
genesis content is the first cell of a skip list. It has no back pointers.
val next :
prev_cell:('content, 'ptr) cell ->
prev_cell_ptr:'ptr ->
'content ->
('content, 'ptr) cellnext ~prev_cell ~prev_cell_ptr content creates a new cell that carries some content, that follows prev_cell.
type ('ptr, 'content) search_result = {rev_path : ('ptr, 'content) cell list;last_cell : ('ptr, 'content) search_cell_result;
}val pp_search_result :
pp_cell:(Format.formatter -> ('ptr, 'content) cell -> unit) ->
Format.formatter ->
('ptr, 'content) search_result ->
unitFunctions in the empty monad are accessible directly.
include MONADIC with type 'a result := 'a
val find :
deref:('ptr -> ('content, 'ptr) cell option) ->
cell_ptr:'ptr ->
target_index:Z.t ->
('content, 'ptr) cell optionfind ~deref ~cell_ptr ~target_index returns Some cell where cell is the cell at position target_index. This is done by dereferencing the last pointer of the path returned by back_path.
val back_path :
deref:('ptr -> ('content, 'ptr) cell option) ->
cell_ptr:'ptr ->
target_index:Z.t ->
'ptr list optionback_path ~deref ~cell_ptr ~target_index returns Some path where path is a sequence of back pointers to traverse to go from cell_ptr to the cell at position target_index in the sequence denoted by (deref, cell_ptr).
val valid_back_path :
equal_ptr:('ptr -> 'ptr -> bool) ->
deref:('ptr -> ('content, 'ptr) cell option) ->
cell_ptr:'ptr ->
target_ptr:'ptr ->
'ptr list ->
boolvalid_back_path ~equal_ptr ~deref ~cell_ptr ~target_ptr path returns true iff path is a valid and minimal path from cell_ptr to target_ptr in the skip list denoted by (deref, cell_ptr).
val search :
deref:('ptr -> ('content, 'ptr) cell option) ->
compare:('content -> int) ->
cell:('content, 'ptr) cell ->
('content, 'ptr) search_resultsearch ~deref ~compare ~cell allows to find a cell of the skip list according to its content. This function assumes that the content of the cells is in increasing order according to the ordering defined by the function compare. In other words, this function assumes that compare is a function that returns a negative integer for cells before the target and a positive integer for cells after the target. The value returned by this function is {rev_path; last_cell} such that.
rev_path = []if and only ifcompare (content cell) > 0
- For all the cases below, if there is a path from cell
Ato cellB,rev_pathcontains the list of cells to go fromBtoA. Consequently, the first element ofrev_pathisB. Except forNearest_lower, this path is a minimal path.
last_pointer = Deref_returned_noneifdereffails to associate a cell to a pointer during the search. In that case,rev_pathis a path fromcelltocandidatewherecandidateis the last cell for which candidate did not fail and such thatcompare (content (candidate)) > 0.
last_pointer = No_exact_or_lower_ptrif for all cell of the skip list,compare (content cell) > 0. In that case,rev_pathis a path fromcellto the genesis cell.
last_pointer = Found targetif there is a celltargetsuch thatcompare (content target) = 0and a path fromcelltotarget. In that case,rev_pathis the minimal path fromcelltotarget.
last_pointer = Nearest_lower {lower;upper}if there is no cell in the skip list such thatcompare (content cell) = 0. In that caseloweris the unique cell such thatcompare (content lower) < 0and for all other cellscandidatesuch thatcompare (content candidate) < 0then there is a path fromlowertocandidate.upper, if it exists is the successor cell tolower, i.e.deref ((back_pointer upper) 0) = Some lower. In that case,rev_pathis a path fromcelltolower. This path is *NOT* minimal but almost. The path is minimal fromcelltoupper=Some up. By minimality, the path is logarithmic. Consequently, since there is a direct pointer fromuptolower, the passe toloweris also logarithmic.
This module contains functions in the Lwt monad.
This functor can be used to build monadic functions for the skip list.