package server-reason-react
Install
Dune Dependency
Authors
Maintainers
Sources
sha256=f7e93b2c24e6420ed7352f5b04ff028ea6ea8b9b91679bbce43aadfcae028f34
sha512=b74f883d8fad95738b7dd9b51f23af27ef1b541939ad9b8ea65cfb0d48a217c2265ca9319e9355c7782bf223a5168ee4ff236677503afa301c8b7b08561fcd8c
doc/server-reason-react.belt/Belt/MutableQueue/index.html
Module Belt.MutableQueue
An FIFO(first in first out) queue data structure
First-in first-out queues.
This module implements queues (FIFOs), with in-place modification.
val make : unit -> 'a t
val clear : 'a t -> unit
Discard all elements from the queue.
val isEmpty : 'a t -> bool
val fromArray : 'a array -> 'a t
fromArray a
is equivalent to Array.forEach a (add q a)
val add : 'a t -> 'a -> unit
add q x
adds the element x
at the end of the queue q
.
val peek : 'a t -> 'a option
peekOpt q
returns the first element in queue q
, without removing it from the queue.
val peekUndefined : 'a t -> 'a Js.undefined
peekUndefined q
returns undefined
if not found
val peekExn : 'a t -> 'a
peekExn q
raise an exception if q
is empty
val pop : 'a t -> 'a option
pop q
removes and returns the first element in queue q
.
val popUndefined : 'a t -> 'a Js.undefined
popUndefined q
removes and returns the first element in queue q
. it will return undefined if it is already empty
val popExn : 'a t -> 'a
popExn q
raise an exception if q
is empty
val size : 'a t -> int
val forEachU : 'a t -> ('a -> unit) -> unit
val forEach : 'a t -> ('a -> unit) -> unit
forEach q f
applies f
in turn to all elements of q
, from the least recently entered to the most recently entered. The queue itself is unchanged.
val reduceU : 'a t -> 'b -> ('b -> 'a -> 'b) -> 'b
val reduce : 'a t -> 'b -> ('b -> 'a -> 'b) -> 'b
reduce q accu f
is equivalent to List.reduce l accu f
, where l
is the list of q
's elements. The queue remains unchanged.
transfer q1 q2
adds all of q1
's elements at the end of the queue q2
, then clears q1
. It is equivalent to the sequence forEach (fun x -> add x q2) q1; clear q1
, but runs in constant time.
val toArray : 'a t -> 'a array
First added will be in the beginning of the array