package sek
Install
dune-project
Dependency
Authors
Maintainers
Sources
md5=9f6928616982931247b976d6ffe26b21
sha512=26e61a6d4a985ffba16f21933c7702b246f41e7f9ad4768fecb8235fd95c26a02ad19708de9b2fcab5ef58c3796d41877df3fe050ba44aa77c615d42db8f8791
doc/sek/Sek/module-type-SEK/index.html
Module type Sek.SEKSource
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 : sideval back : sideA side appears as a parameter to several operations, such as push and pop, 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 forward is +1. sign backward is -1.
The exception Empty is raised by pop and peek operations when applied to an empty sequence.
The exception End is raised by the iterator operations get, get_segment, get_and_move, and get_segment_and_jump when the iterator has moved past the end of the sequence.
module Ephemeral : sig ... endThe submodule Ephemeral, also available under the name E, offers an implementation of ephemeral (mutable) sequences. Please follow the link for details.
module Persistent : sig ... endThe submodule Persistent, also available under the name P, offers an implementation of persistent (immutable) sequences. Please follow the link for details.
module P = PersistentP is a short name for the submodule Persistent.
Conversion Functions
The following functions offer fast conversions between ephemeral and persistent sequences.
val snapshot : 'a Ephemeral.t -> 'a Persistent.tsnapshot s constructs and returns a persistent sequence whose elements are the elements of s. It is less efficient than snapshot_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 s constructs and returns a persistent sequence whose elements are the elements of an ephemeral sequence s. As a side effect, it clears s.
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 of push operations, the cost of snapshot_and_clear may be charged to these push operations, allowing one to consider that snapshot_and_clear costs O(1).
val edit : 'a Persistent.t -> 'a Ephemeral.tedit s constructs and returns a new ephemeral sequence whose elements are the elements of s.
Time complexity: O(K).
Emulation Layers
module Emulated : sig ... endThe submodule Emulated contains Sek-based replacements for several modules in OCaml's standard library: Array, List, Queue, Stack.
Miscellaneous
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 ... endThe module Segment offers facilities for working with array segments. An array segment is a triple of an array, a start index, and a length.