Module Sek.Segment
The module Segment offers facilities for working with array segments. An array segment is a triple of an array, a start index, and a length.
val is_valid : 'a segment -> boolis_valid (a, i, k)determines whether the indexiand lengthkdefine a valid segment of the arraya.is_validis O(1).
val is_empty : 'a segment -> boolis_empty segdetermines whether the array segmentsegis empty.
val iter : direction -> 'a segment -> ('a -> unit) -> unititer direction seg fapplies the functionfin turn to every element of the array segmentseg. The direction of iteration is dictated by the parameterdirection. Ifsegis of the form(a, i, k), theniterhas complexity O(k), excluding the cost of the calls tof.
val iter2 : direction -> 'a segment -> 'b segment -> ('a -> 'b -> unit) -> unititer2 direction seg1 seg2 fapplies the functionfin turn to every pair of elements drawn synchronously from the the array segmentsseg1andseg2. The two segments must have the same size. The direction of iteration is dictated by the parameterdirection.iter2has complexity O(n), excluding the cost of the calls tof, where n denotes the the size of the two segments.