Module Sek.Make
The functor Make constructs an implementation of the signature SEK, and allows the user to choose the value of the settings described above. Be warned, however, that the number and the nature of the settings expected by this functor may change in the future. A relatively forward-compatible way of using this functor is to always pass it a structure that is built by including the structure DefaultSettings and overriding the definition of one or more settings.
Parameters
Settings : sig ... end
Signature
val front : sideval back : sideA side appears as a parameter to several operations, such as
pushandpop, which can operate at either end of a sequence.
val forward : directionval backward : directionA direction appears as a parameter to several operations, such as
iter, which can traverse the sequence either forward (from front to back) or backward (from back to front).
val sign : direction -> intsign forwardis+1.sign backwardis-1.
exceptionEmptyThe exception
Emptyis raised bypopandpeekoperations when applied to an empty sequence.
exceptionEndThe exception
Endis raised by the iterator operationsget,get_segment,get_and_move, andget_segment_and_jumpwhen the iterator has moved past the end of the sequence.
module Ephemeral : sig ... endThe submodule
Ephemeral, also available under the nameE, offers an implementation of ephemeral (mutable) sequences. Please follow the link for details.
module Persistent : sig ... endThe submodule
Persistent, also available under the nameP, offers an implementation of persistent (immutable) sequences. Please follow the link for details.
module P = PersistentPis a short name for the submodulePersistent.
Conversion Functions
val snapshot : 'a Ephemeral.t -> 'a Persistent.tsnapshot sconstructs and returns a persistent sequence whose elements are the elements ofs. It is less efficient thansnapshot_and_clear, whose use should be preferred, when possible.Time complexity: O(K). Note that this operation introduces sharing: therefore, it may increase the cost of subsequent operations.
val snapshot_and_clear : 'a Ephemeral.t -> 'a Persistent.tsnapshot_and_clear sconstructs and returns a persistent sequence whose elements are the elements of an ephemeral sequences. As a side effect, it clearss.Time complexity: O(min(K,n)). In other words, the cost is always O(K) and, in the specific case of short sequences, it is only O(n).
In the particular case where the ephemeral sequence
shas been constructed by applying a series ofpushoperations, the cost ofsnapshot_and_clearmay be charged to thesepushoperations, allowing one to consider thatsnapshot_and_clearcosts O(1).
val edit : 'a Persistent.t -> 'a Ephemeral.tedit sconstructs and returns a new ephemeral sequence whose elements are the elements ofs.Time complexity: O(K).
Emulation Layers
Miscellaneous
val released : unit -> unitThe function call
released()does nothing if the library was compiled in release mode, and fails (with an assertion failure) if the library was compiled with assertions enabled.
module Segment : sig ... endThe module
Segmentoffers facilities for working with array segments. An array segment is a triple of an array, a start index, and a length.