Module type PrivateSignatures.ECHUNK
The module EphemeralChunk implements an ephemeral chunk, that is, a mutable circular buffer. This is its signature.
type 'a tA chunk is a mutable object, which represents a sequence of elements of type
'a. A chunk has a fixed capacity, which it cannot exceed.
val check : 'a t -> unitcheck cverifies that the chunkcis valid, i.e., that its internal invariant is satisfied.
val create : 'a -> Sek__.PublicTypeAbbreviations.capacity -> 'a tcreate d ncreates a fresh chunk whose capacity isn. The default elementdis used to initialize empty slots. Ifoverwrite_empty_slotsistrue, then it is also used to overwrite a slot that becomes empty, e.g., inpopandcarve_back.
val make : 'a -> Sek__.PublicTypeAbbreviations.capacity -> Sek__.PublicTypeAbbreviations.length -> 'a -> 'a tmake d n k vcreates a fresh chunk whose default element isd, whose capacity isn, and which contains a sequence ofkcopies of the valuev. The integerkmust be no greater thann.
val init : 'a -> Sek__.PublicTypeAbbreviations.capacity -> Sek__.PublicTypeAbbreviations.length -> Sek__.PublicTypeAbbreviations.index -> (Sek__.PublicTypeAbbreviations.index -> 'a) -> 'a tinit d n k i fcreates a fresh chunk whose default element isd, whose capacity isn, and which contains the sequence of values produced by the callsf i,f (i+1), ...f (i+k-1), in this order. The integerkmust be no greater thann.
val dummy : 'a -> 'a tdummy dcreates a dummy (invalid!) chunk, which can be used as a default element when creating a chunk of chunks. This dummy chunk is invalid and must not be used. As an exception to this rule, it is permitted to applyis_emptyandis_fullto a dummy chunk; in that case, they both returntrue.
val is_dummy : 'a t -> boolis_dummy ctells whethercis a dummy chunk, that is, whether it has been built bydummy.
val of_array_segment : 'a -> Sek__.PublicTypeAbbreviations.capacity -> 'a array -> Sek__.PublicTypeAbbreviations.index -> Sek__.PublicTypeAbbreviations.length -> 'a tof_array_segment d n a head sizecreates a chunk by copying data from the array segment defined by the arraya, the start indexhead, and the sizesize. The chunk has capacitynand default valued.sizemust be less than or equal ton.
val default : 'a t -> 'adefault creturns the default element that was provided when the chunkcwas created.
val length : 'a t -> Sek__.PublicTypeAbbreviations.lengthlength cis the length of the sequencec.
val capacity : 'a t -> Sek__.PublicTypeAbbreviations.capacitycapacity cis the capacity of the chunkc, that is, the maximum number of elements that this chunk can hold.
val data : 'a t -> 'a arraydata cis the raw array that underlies the chunkc. This function is dangerous; it should be used only to implement efficient iterators.
val is_empty : 'a t -> boolis_empty cis equivalent tolength c = 0.
val is_full : 'a t -> boolis_full cis equivalent tolength c = capacity c.
val is_empty_or_dummy : 'a t -> boolis_empty_or_dummy cis equivalent tois_empty c || is_dummy c.
val is_full_or_dummy : 'a t -> boolis_full_or_dummy cis equivalent tois_full c || is_dummy c.
val get : 'a t -> Sek__.PublicTypeAbbreviations.index -> 'aget c ireturns the element found at indexiin the sequencec.imust be comprised between 0 included andlength cexcluded.
val set : 'a t -> Sek__.PublicTypeAbbreviations.index -> 'a -> unitset c i xreplaces the element found at indexiin the sequencecwith the valuex.imust be comprised between 0 included andlength cexcluded.
val peek : pov -> 'a t -> 'apeek pov creturns the first or last element of the chunkc, depending on the point-of-viewpov. The chunkcmust be nonempty.
val push : pov -> 'a t -> 'a -> unitpush pov c xinserts the elementxat the front or back of the chunkc, depending on the point-of-viewpov. The chunkcmust not be full.
val pop : pov -> 'a t -> 'apop pov cextracts and returns the first or last element of the chunkc, depending on the point-of-viewpov. The chunkcmust be nonempty.
val copy : 'a t -> 'a tcopy ccreates and returns a copy of the chunkc. The copy is identical to the original chunk, but is disjoint fromc, so an update to the copy does not affectc.
val clear : 'a t -> unitclear cupdates the chunkcso that it represents the empty sequence.
val carve_back : 'a t -> Sek__.PublicTypeAbbreviations.index -> 'a tcarve_back c isplits the sequencecat indexi. The indeximust be comprised between 0 included andlength cincluded. After this operation, the chunkcis truncated and represents the first part of the sequence, up to indexiexcluded. A new chunk, which represents the second part of the sequence, beginning at indexi, is returned.
val take : 'a t -> Sek__.PublicTypeAbbreviations.index -> unittake c itruncates the sequencecat indexi. The indeximust be comprised between 0 included andlength cincluded. After this operation, the chunkcis truncated and represents the first part of the sequence, up to indexiexcluded.
val drop : 'a t -> Sek__.PublicTypeAbbreviations.index -> unitdrop c itruncates the sequencecat indexi. The indeximust be comprised between 0 included andlength cincluded. After this operation, the chunkcis truncated and represents the second part of the sequence, beginning at indexi.
val print : ('a -> PPrint.document) -> 'a t -> PPrint.documentprintis a chunk printer, parameterized with an element printer. It is intended to be used only while debugging.
module View : sig ... endval view : 'a t -> View.viewview cis a view that covers all of the elements currently found in the chunkc.
val iter_segments : pov -> 'a t -> 'a Sek__.PublicTypeAbbreviations.segmentsiter_segments pov creturns a sequence of up to two array segments that cover the chunkc. It is analogous toView.iter_segmentsabove, but applies to the entire chunk (not to a view). It is permitted to applyiter_segmentsto a dummy chunk.