Module ShareableSequence.Make
Parameters
Signature
type 'a schunk= 'a SChunk.ttype 'a measure= 'a SChunk.measure=|MUnit : 'a measure|MSWeight : 'a schunk measuretype 'a t=|Zero of{default : 'a;}|One of{default : 'a;x : 'a;}|Short of{default : 'a;a : 'a array;}|Level of{weight : Sek__.PrivateSignatures.weight;front : 'a schunk;middle : 'a schunk t;back : 'a schunk;}This is the structure of a shareable sequence.
val create : 'a -> 'a tcreate defaultis an empty sequence.
val make : 'a -> Sek__.PublicTypeAbbreviations.length -> 'a -> Sek__.PrivateSignatures.owner -> 'a tmake default n v ocreates a sequence that consists ofncopies of the valuev. This sequence has depth0.
val init : 'a -> Sek__.PublicTypeAbbreviations.length -> (Sek__.PublicTypeAbbreviations.index -> 'a) -> Sek__.PrivateSignatures.owner -> 'a tinit default n f ocreates a sequence that consists of the values produced by the callsf 0,f 1, ...f (n-1), in this order. This sequence has depth0.
val nonempty_level : Sek__.PrivateSignatures.pov -> Sek__.PrivateSignatures.weight -> 'a schunk -> 'a schunk t -> 'a schunk -> 'a tnonempty_level pov weight this middle thatconstructs a nonempty sequence whose front (resp. back) isthis, whose middle ismiddle, and whose back (resp. front) isthat.weightmust be the total weight of the elements in the sequence, and must be nonzero.
val create_middle : 'a -> 'a schunk tval default : 'a t -> 'adefault sreturns a default element. (This element was provided as a default element in one of the operations that contributed to the construction ofs.)
val weight : 'a t -> Sek__.PrivateSignatures.weightweight sis the total weight of the elements of the sequences.
val is_empty : 'a t -> boolis_empty sdetermines whether the sequencesis empty.
val dummy : 'a t -> 'a schunkdummy sextracts a dummy schunk out ofs, if possible; otherwise, it creates a fresh one.
val check : 'a t -> 'a measure -> Sek__.PrivateSignatures.owner -> Sek__.PublicTypeAbbreviations.depth -> unitcheck s m o depthverifies that the sequencesis valid with respect to measurem, ownero, and depthdepth.
val check_middle : 'a schunk t -> 'a measure -> Sek__.PrivateSignatures.owner -> Sek__.PublicTypeAbbreviations.depth -> unitcheck_middle middle m o depthverifies that the sequencemiddleis valid with respect to measurem, ownero, and depthdepth. This includes checking that it is a valid sequence, checking that its elements are valid schunks, and verifing that the density invariant holds.
val push : Sek__.PrivateSignatures.pov -> 'a t -> 'a -> 'a measure -> Sek__.PrivateSignatures.owner -> Sek__.PublicTypeAbbreviations.depth -> 'a tpush pov s x m o depthconstructs and returns a new sequence obtained by pushing the elementxonto the front or back end of the sequences.
val pop : Sek__.PrivateSignatures.pov -> 'a t -> 'a measure -> Sek__.PrivateSignatures.owner -> 'a * 'a tIf the sequence
sis nonempty, thenpop pov s m oreturns a pair of the elementxfound at the front or back end of the sequencesand of the sequencesdeprived ofx. If the sequencesis empty, the exceptionEmptyis raised.
val peek : Sek__.PrivateSignatures.pov -> 'a t -> 'aIf the sequence
sis nonempty, thenpeek pov sreads the elementxfound at the front or back end of the sequencesand returnsx. If the sequencesis empty, the exceptionEmptyis raised.
val get : 'a t -> Sek__.PrivateSignatures.weight -> 'a measure -> Sek__.PrivateSignatures.weight * 'aget s i mis equivalent tolet s1, x, s2 = three_way_split s i m o in (i - weight s1, x). Thus, it returns a pair of the elementxwithin which the weightifalls and the indeximinus the weight of the elements located towards the left ofx.
val set : 'a t -> Sek__.PrivateSignatures.weight -> 'a measure -> Sek__.PrivateSignatures.owner -> 'a -> 'a tset s i m o xreturns a new sequence obtained by replacing the element within which the weightifalls with the new elementx. The old and new element must have the same weight.
val update : 'a measure -> Sek__.PrivateSignatures.owner -> 'a Sek__.PrivateSignatures.update -> 'a t Sek__.PrivateSignatures.updateupdate m o f s iapplies the updatefat weight-indexiin the sequences. The update functionfis itself parameterized with the weight-index at which the update should be applied.
val fuse_back : 'a schunk t -> 'a schunk -> Sek__.PrivateSignatures.owner -> Sek__.PublicTypeAbbreviations.depth -> 'a schunk tfuse_back middle p o depthpushes the schunkponto the back ofmiddle, which is a sequence of schunks. If possible, the last schunk of the sequence and the schunkpare fused into a single schunk. By convention, passdepth, notdepth + 1--fuse_backtakes care of adding one.
val fuse : 'a schunk t -> 'a schunk t -> Sek__.PrivateSignatures.owner -> Sek__.PublicTypeAbbreviations.depth -> 'a schunk tfuse s1 s2 o depthconcatenates the sequencess1ands2, which are sequences of schunks. It attempts to fuse the last schunk ofs1and the first schunk ofs2, so as to preserve the fill invariant. By convention, passdepth, notdepth + 1--fusetakes care of adding one.
val concat : 'a t -> 'a t -> Sek__.PrivateSignatures.owner -> Sek__.PublicTypeAbbreviations.depth -> 'a tconcat s1 s2 o depthconcatenates the sequencess1ands2.
val three_way_split : 'a t -> Sek__.PrivateSignatures.weight -> 'a measure -> Sek__.PrivateSignatures.owner -> 'a t * 'a * 'a tthree_way_split s i m osplits the sequencesinto a sequences1, followed with an elementx, followed with a sequences2, such that the weightifalls within the elementx, that is,weight s1 <= i < weight s1 + apply m xholds. The weightimust be comprised between 0 included andweight sexcluded.
val take : 'a t -> Sek__.PrivateSignatures.weight -> 'a measure -> Sek__.PrivateSignatures.owner -> 'a t * 'atakeis a specialized version ofthree_way_split. Instead of returning a triples1, x, s2, it returns a pairs1, x.
val drop : 'a t -> Sek__.PrivateSignatures.weight -> 'a measure -> Sek__.PrivateSignatures.owner -> 'a * 'a tdropis a specialized version ofthree_way_split. Instead of returning a triples1, x, s2, it returns a pairx, s2.
val to_array : 'a t -> 'a arrayto_array sreturns a fresh array whose elements are the elements of the sequences.
val of_array_segment : 'a -> 'a array -> Sek__.PublicTypeAbbreviations.index -> Sek__.PublicTypeAbbreviations.length -> Sek__.PrivateSignatures.owner -> 'a tof_array_segment default a head size ocreates a sequence out of the array segment defined by the arraya, the start indexhead, and the sizesize. This function only makes sense at depth0.
val iter : Sek__.PrivateSignatures.pov -> ('a -> unit) -> 'a t -> unititer pov f sapplies the functionfin turn to every element in the sequences, in the order specified by the point-of-viewpov.
val iter_segments : Sek__.PrivateSignatures.pov -> 'a t -> 'a Sek__.PublicTypeAbbreviations.segmentsiter_segments pov sreturns a sequence of array segments that store the data of the sequences.