package core_kernel

  1. Overview
  2. Docs
Legend:
Library
Module
Module type
Parameter
Class
Class type

A simple polymorphic functional queue. Use this data structure for strictly first-in, first-out access to a sequence of values. For a similar data structure with enqueue and dequeue accessors on both ends of a sequence, see Core_kernel.Fdeque.

Amortized running times assume that enqueue/dequeue are used sequentially, threading the changing Fqueue through the calls.

type 'a t
val bin_t : 'a Bin_prot.Type_class.t -> 'a t Bin_prot.Type_class.t
val bin_read_t : 'a Bin_prot.Read.reader -> 'a t Bin_prot.Read.reader
val __bin_read_t__ : 'a Bin_prot.Read.reader -> (Base.Int.t -> 'a t) Bin_prot.Read.reader
val bin_reader_t : 'a Bin_prot.Type_class.reader -> 'a t Bin_prot.Type_class.reader
val bin_size_t : 'a Bin_prot.Size.sizer -> 'a t Bin_prot.Size.sizer
val bin_write_t : 'a Bin_prot.Write.writer -> 'a t Bin_prot.Write.writer
val bin_writer_t : 'a Bin_prot.Type_class.writer -> 'a t Bin_prot.Type_class.writer
val bin_shape_t : Bin_prot.Shape.t -> Bin_prot.Shape.t
val compare : ('a -> 'a -> Base.Int.t) -> 'a t -> 'a t -> Base.Int.t
val hash_fold_t : (Ppx_hash_lib.Std.Hash.state -> 'a -> Ppx_hash_lib.Std.Hash.state) -> Ppx_hash_lib.Std.Hash.state -> 'a t -> Ppx_hash_lib.Std.Hash.state
val t_of_sexp : (Ppx_sexp_conv_lib.Sexp.t -> 'a) -> Ppx_sexp_conv_lib.Sexp.t -> 'a t
val sexp_of_t : ('a -> Ppx_sexp_conv_lib.Sexp.t) -> 'a t -> Ppx_sexp_conv_lib.Sexp.t
val mem : 'a t -> 'a -> equal:('a -> 'a -> bool) -> bool
val iter : 'a t -> f:('a -> unit) -> unit
val fold : 'a t -> init:'accum -> f:('accum -> 'a -> 'accum) -> 'accum
val fold_result : 'a t -> init:'accum -> f:('accum -> 'a -> ('accum, 'e) Base__.Result.t) -> ('accum, 'e) Base__.Result.t
val fold_until : 'a t -> init:'accum -> f:('accum -> 'a -> ('accum, 'final) Base__.Container_intf.Continue_or_stop.t) -> finish:('accum -> 'final) -> 'final
val exists : 'a t -> f:('a -> bool) -> bool
val for_all : 'a t -> f:('a -> bool) -> bool
val count : 'a t -> f:('a -> bool) -> int
val sum : (module Base__.Commutative_group.S with type t = 'sum) -> 'a t -> f:('a -> 'sum) -> 'sum
val find : 'a t -> f:('a -> bool) -> 'a option
val find_map : 'a t -> f:('a -> 'b option) -> 'b option
val to_array : 'a t -> 'a array
val min_elt : 'a t -> compare:('a -> 'a -> int) -> 'a option
val max_elt : 'a t -> compare:('a -> 'a -> int) -> 'a option
val invariant : 'a Base__.Invariant_intf.inv -> 'a t Base__.Invariant_intf.inv
val (>>=) : 'a t -> ('a -> 'b t) -> 'b t
val (>>|) : 'a t -> ('a -> 'b) -> 'b t
module Monad_infix : sig ... end
val bind : 'a t -> f:('a -> 'b t) -> 'b t
val return : 'a -> 'a t
val map : 'a t -> f:('a -> 'b) -> 'b t
val join : 'a t t -> 'a t
val ignore_m : 'a t -> unit t
val all : 'a t list -> 'a list t
val all_unit : unit t list -> unit t
val all_ignore : unit t list -> unit t
  • deprecated [since 2018-02] Use [all_unit]
module Let_syntax : sig ... end
val empty : 'a t

The empty queue.

val enqueue : 'a t -> 'a -> 'a t

enqueue t x returns a queue with adds x to the end of t. Complexity: O(1).

val enqueue_top : 'a t -> 'a -> 'a t

Enqueues a single element on the *top* of the queue. Complexity: amortized O(1) enqueue_top is deprecated, use Fdeque.t instead.

val bot_exn : 'a t -> 'a

Returns the bottom (most recently enqueued) element. Raises Empty if no element is found. Complexity: O(1).

bot_exn is deprecated, use Fdeque.t instead.

val bot : 'a t -> 'a Base.Option.t

Like bot_exn, but returns its result optionally, without exception. Complexity: O(1).

bot is deprecated, use Fdeque.t instead.

val top_exn : 'a t -> 'a

Like bot_exn, except returns top (least recently enqueued) element. Complexity: O(1).

val top : 'a t -> 'a Base.Option.t

Like top_exn, but returns its result optionally, without exception, Complexity: O(1).

val dequeue_exn : 'a t -> 'a * 'a t

dequeue_exn t removes and returns the front of t, raising Empty if t is empty. Complexity: amortized O(1)

val dequeue : 'a t -> ('a * 'a t) Base.Option.t

Like dequeue_exn, but returns result optionally, without exception. Complexity: amortized O(1)

val discard_exn : 'a t -> 'a t

Returns version of queue with top element removed. Complexity: amortized O(1).

val to_list : 'a t -> 'a Base.List.t

to_list t returns a list of the elements in t in order from least-recently-added (at the head) to most-recently-added (at the tail). Complexity: O(n).

val of_list : 'a Base.List.t -> 'a t

of_list is the inverse of to_list. Complexity: O(n).

val length : 'a t -> Base.Int.t

Complexity: O(1).

val is_empty : 'a t -> Base.Bool.t

Complexity: O(1).

val singleton : 'a -> 'a t
module Stable : sig ... end
OCaml

Innovation. Community. Security.