package sek

  1. Overview
  2. Docs

Module Sek.MakeSource

The functor Make constructs an implementation of the signature SEK, and allows the user to choose the value of the parameters described above. Be warned, however, that the number and types of the parameters of this functor may change in the future. Users who want maximum forward compatibility should not use this functor.

Parameters

module C : CAPACITY
module T : THRESHOLD

Signature

Sourcetype side
Sourceval front : side
Sourceval back : side

A side appears as a parameter to several operations, such as push and pop, which can operate at either end of a sequence.

Sourcetype direction
Sourceval forward : direction
Sourceval 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).

Sourceexception Empty

The exception Empty is raised by pop and peek operations when applied to an empty sequence.

Sourcemodule Ephemeral : sig ... end

The submodule Ephemeral, also available under the name E, offers an implementation of ephemeral (mutable) sequences.

Sourcemodule Persistent : sig ... end

The submodule Persistent, also available under the name P, offers an implementation of persistent (immutable) sequences.

Sourcemodule E = Ephemeral

E is a short name for the submodule Ephemeral.

Sourcemodule P = Persistent

P is a short name for the submodule Persistent.

Conversion Functions

The following functions offer fast conversions between ephemeral and persistent sequences.

Sourceval snapshot : 'a Ephemeral.t -> 'a Persistent.t

snapshot 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.

Sourceval 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 s. As a side effect, it clears s.

Sourceval edit : 'a Persistent.t -> 'a Ephemeral.t

edit s constructs and returns a new ephemeral sequence whose elements are the elements of s.

Emulation Layers

Sourcemodule Queue : sig ... end

The submodule Queue is a replacement for OCaml's standard Queue module, where a queue is implemented as an ephemeral sequence. Elements are enqueued at the back end of the sequence and dequeued at the front end.

Sourcemodule Stack : sig ... end

The submodule Stack is a replacement for OCaml's standard Stack module, where a stack is implemented as an ephemeral sequence. Elements are pushed and popped at the front end of the sequence.

Miscellaneous

Sourceval 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.