package base
Install
dune-project
Dependency
Authors
Maintainers
Sources
md5=109456ad2350671ad3159cbbca993e3e
sha512=445d08b965e0d559e4046b874f611c8f36de47fa5c23a047146f48ee638588c1b73789a7adb5ead235c0ad2f44b56fd513a6d60bcb8b6c9f11566d32fd7760f2
doc/base/Base/Ordered_collection_common/index.html
Module Base.Ordered_collection_commonSource
Functions for ordered collections.
get_pos_len_exn, and check_pos_len_exn are intended to be used by functions that take a sequence (array, string, bigstring, ...) and an optional pos and len specifying a subrange of the sequence. Such functions should call get_pos_len with the length of the sequence and the optional pos and len, and it will return the pos and len specifying the range, where the default pos is zero and the default len is to go to the end of the sequence.
It should be the case that:
pos >= 0 && len >= 0 && pos + len <= total_lengthNote that this allows pos = total_length and len = 0, i.e., an empty subrange at the end of the sequence.
get_pos_len_exn returns (pos', len') specifying a subrange where:
pos' = match pos with None -> 0 | Some i -> i len' = match len with None -> total_length - pos' | Some i -> i
check_pos_len_exn ~pos ~len ~total_length raises unless pos >= 0 && len >= 0 && pos + len <= total_length.
Like get_pos_len_exn. Returns an Or_error.t.