package orsetto
Install
dune-project
Dependency
Authors
Maintainers
Sources
sha256=6e6f59fc6a2c590b1b377e40f2120a548e6f09e61e7eb12ffa45cf2d517316b8
md5=533153cd4a9fe8093d3b98afc1073bc8
doc/orsetto.cf/Cf_slice/index.html
Module Cf_slice
Slices of basic vector types, i.e. arrays, byte sequences and string.
Type
type 'a t = private {vector : 'a;(*The type of the underlying vector.
*)start : int;(*Index in
*)vectorof element at start of slice.limit : int;(*Index in
*)vectorof element after end of slice.
}The type of a vector slice.
Constructors
val of_vector : ('a -> int) -> 'a -> 'a tUse of_vector f v to make a slice of v referencing the entire range of v starting at index zero and limiting at the index obtained by applying f v. Raises Failure if f returns a negative integer.
val of_subvector : ('a -> int) -> 'a -> int -> int -> 'a tUse of_subvector f v start limit to make a slice that references the part of v starting at index start and limiting at index limit. Raises Invalid_argument if start > limit or if either start or limit are not valid indexes in v, where valid indexes are non-negative integers less than the result of f v. Raises Failure if f returns a negative integer.
val of_array : 'a array -> 'a array tUse of_array a to make a slice that references all of a.
val of_subarray : 'a array -> int -> int -> 'a array tUse of_subarray a start limit to make a slice that references the part of a that starts at index start and is limited at index limit.
val of_bytes : bytes -> bytes tUse of_bytes b to make a slice that references all of b.
val of_subbytes : bytes -> int -> int -> bytes tUse of_subbytes b start limit to make a slice that references the part of b that starts at index start and is limited at index limit.
val of_string : string -> string tUse of_string s to make a slice that references all of s.
val of_substring : string -> int -> int -> string tUse of_substring s start limit to make a slice that references the part of s that starts at index start and is limited at index limit.
Conversions
val to_vector : ('a -> int -> int -> 'a) -> 'a t -> 'aUse to_vector f s to copy the values in s into a new vector by evaluating f start length where start is the starting index of the slice and length is the difference between the limit and the start.
val to_string : string t -> stringUse to_string s to copy the octets in s into a new string.
val to_array : 'a array t -> 'a arrayUse to_array s to copy the elements in s into a new array.
Use to_elements s to make a sequence of the elements in s. Elements are read from the array as the sequence is evaluated.
Interface
val length : 'a t -> intUse length s to obtain the length of s in elements.
Use truncate n s to make a new slice that references the first n elements in s. Raises Invalid_argument if n is not a valid index into s.
Use shift n s to make a new slice that references the remaining elements in s after the first n. Raises Invalid_argument if n is not a valid index into s.
Use split n s to make two slices that reference the same mutable or immutable sequences as s. The first slice comprises the first n elements of s, and the second slice comprises the remaining elements of s. Raises Invalid_argument if n is not a valid index into s.