

The parameter side determines which end of the sequence is acted upon. If the sequence s is nonempty, then pop side s pops an element x off the front or back end of the sequence s and returns x. That said, in practice, most push operations execute in O(1). Time complexity: O(log n) in the worst case. Push side s x pushes the element x onto the front or back end of the sequence s. Stack Operations val push : side -> 'a t -> 'a -> unit Time complexity: O(1) in the special case where s2 is never used afterwards otherwise O(K). If s1 and s2 are the same sequence, then assign s1 If s1 and s2 are distinct sequences, then assign s1 s2 moves s2's elements into s1, overwriting s1's previous content, and clears s2. Time complexity: O(n + K) in `Share mode O(K) in `Copy mode. That is, copy s is a short-hand for copy ~mode:`Copy s.
#INTERVALS EPHEMERAL UPDATE#
This operation has complexity O(K), which is fast, but on the downside, there is a latent cost: subsequent update operations on s and s' are more costly. The copying of individual chunks is delayed until s or s' is actually modified.


val init : 'a -> length -> ( index -> 'a) -> 'a t It is equivalent to of_array default (Array.make n v). Make default n v constructs and returns a fresh sequence whose length is n and which consists of n copies of the value v. The default value default is used to fill empty array slots. Construction val create : 'a -> 'a tĬreate default constructs and returns a new empty sequence. Please follow the link for details.Ī sequence s of type 'a t is a mutable data structure which represents a mathematical sequence of elements of type 'a. The submodule Ephemeral, also available under the name E, offers an implementation of ephemeral (mutable) sequences. Up – sek » Sek » Make » Ephemeral Module Make.Ephemeral
