package slice
Install
dune-project
Dependency
Authors
Maintainers
Sources
sha256=4a9073caf8c5eb502e002a54910b1477300f1bc27aadfa286370e336ade3ba8e
sha512=510478a62438caffa6eece71938bc4eb24305ed31743ab1389ec9951e85a22242c1392bf4872051497e7be80613c7a68e9c8cb74e4ed36c106e8fa0f5d24181c
doc/slice.bstr/Slice_bstr/index.html
Module Slice_bstrSource
Slices on a bigstring (Bstr.t).
This module implements Slice.S: it offers exactly the same API as Slice_bytes (and mirrors Bstr), so that the same code can be used regardless of the underlying byte sequence.
sub and shift are O(1): they share the underlying bigstring with the given slice instead of calling Bstr.sub (which is about 8 times slower).
This module is the result of a poor man's functor designed to avoid the inherent overhead that can arise from using functors in OCaml. In other words, the implementation is the same as that of Slice_bytes.
include Slice.S with type buf = Bstr.t
include Slice.R with type buf := buf and type t := t
create len is a fresh t of length len. Its contents are reset to zero (bytes are set to '\000').
make ~off ~len buf is the view of buf which starts at off (defaults to 0) and which is len bytes long (defaults to length buf - off). The buffer is not copied.
init len fn is t of length len with index idx holding the character fn idx (called in increasing index order).
chop t is Some (get t idx) with idx = 0 if rev = false (default) or idx = length t - 1 if rev = true. None is returned if t is empty.
get t i is the byte of t at index i.
Bounds are the ones of the slice, not the ones of the underlying buffer: a slice never gives access to a byte which is outside of its own range.
get_int8 bstr i is bstr's signed 8-bit integer starting at byte index i.
get_uint8 bstr i is bstr's unsigned 8-bit integer starting at byte index i.
get_uint16_ne slice i is slice's native-endian unsigned 16-bit integer starting at byte index i.
get_uint16_le slice i is slice's little-endian unsigned 16-bit integer starting at byte index i.
get_uint16_be slice i is slice's big-endian unsigned 16-bit integer starting at byte index i.
get_int16_ne slice i is slice's native-endian signed 16-bit integer starting at byte index i.
get_int16_le slice i is slice's little-endian signed 16-bit integer starting at byte index i.
get_int16_be slice i is slice's big-endian signed 16-bit integer starting at byte index i.
get_int32_ne slice i is slice's native-endian 32-bit integer starting at byte index i.
get_int32_le slice i is slice's little-endian 32-bit integer starting at byte index i.
get_int32_be slice i is slice's big-endian 32-bit integer starting at byte index i.
get_int64_ne slice i is slice's native-endian 64-bit integer starting at byte index i.
get_int64_le slice i is slice's little-endian 64-bit integer starting at byte index i.
get_int64_be slice i is slice's big-endian 64-bit integer starting at byte index i.
filter sat slice is a fresh slice made of the bytes of slice that satisfy sat, in the same order.
filter_map fn t is a fresh slice made of the bytes of t as mapped by fn, in the same order.
is_prefix ~affix slice is true iff affix.[idx] = get slice idx for all indices idx of affix.
is_suffix ~affix slice is true iff affix.[n - idx] = get slice (m - idx) for all indices idx of affix with n = String.length affix - 1 and m = length slice - 1.
is_infix ~affix slice is true iff there exists an index j in slice such that for all indices i of affix we have affix.[i] = get t (j + i).