Module type Sek__PublicSignature.SEK
The signature SEK
is the public API of the library. If you are a new user, you do not need to follow this link: the library's API appears below anyway. Just read on!
val front : side
val back : side
A side appears as a parameter to several operations, such as
push
andpop
, which can operate at either end of a sequence.
val forward : direction
val backward : direction
A 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 -> int
sign forward
is+1
.sign backward
is-1
.
exception
Empty
The exception
Empty
is raised bypop
andpeek
operations when applied to an empty sequence.
exception
End
The exception
End
is raised by the iterator operationsget
,get_segment
,get_and_move
, andget_segment_and_jump
when the iterator has moved past the end of the sequence.
module Ephemeral : sig ... end
The submodule
Ephemeral
, also available under the nameE
, offers an implementation of ephemeral (mutable) sequences. Please follow the link for details.
module Persistent : sig ... end
The submodule
Persistent
, also available under the nameP
, offers an implementation of persistent (immutable) sequences. Please follow the link for details.
module P = Persistent
P
is a short name for the submodulePersistent
.
Conversion Functions
val snapshot : 'a Ephemeral.t -> 'a Persistent.t
snapshot s
constructs 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.t
snapshot_and_clear s
constructs 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
s
has been constructed by applying a series ofpush
operations, the cost ofsnapshot_and_clear
may be charged to thesepush
operations, allowing one to consider thatsnapshot_and_clear
costs O(1).
val edit : 'a Persistent.t -> 'a Ephemeral.t
edit s
constructs and returns a new ephemeral sequence whose elements are the elements ofs
.Time complexity: O(K).
Emulation Layers
Miscellaneous
val released : unit -> unit
The 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 ... end
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.