package core_kernel

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

A queue implemented with an array.

The implementation will grow the array as necessary. The array will never automatically be shrunk, but the size can be interrogated and set with capacity and set_capacity.

Iteration functions (iter, fold, map, concat_map, filter, filter_map, filter_inplace, and some functions from Container.S1) will raise if the queue is modified during iteration.

Also see Linked_queue, which has different performance characteristics.

type 'a t
include sig ... end
val compare : ('a -> 'a -> Base.Int.t) -> 'a t -> 'a t -> Base.Int.t
include sig ... end
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_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_shape_t : Bin_prot.Shape.t -> Bin_prot.Shape.t
include Base.Queue_intf.S with type 'a t := 'a t
val t_of_sexp : (Base__.Sexplib.Sexp.t -> 'a) -> Base__.Sexplib.Sexp.t -> 'a t
val sexp_of_t : ('a -> Base__.Sexplib.Sexp.t) -> 'a t -> Base__.Sexplib.Sexp.t
val mem : 'a t -> 'a -> equal:('a -> 'a -> bool) -> bool
val length : 'a t -> int
val is_empty : 'a t -> 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, 'stop) Base__.Container_intf.Continue_or_stop.t) -> ('accum, 'stop) Base__.Container_intf.Finished_or_stopped_early.t
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_list : 'a t -> 'a list
val to_array : 'a t -> 'a array
val min_elt : 'a t -> cmp:('a -> 'a -> int) -> 'a option
val max_elt : 'a t -> cmp:('a -> 'a -> int) -> 'a option
val foldi : ('a t, 'a, 'b) Base__.Indexed_container_intf.foldi
val iteri : ('a t, 'a) Base__.Indexed_container_intf.iteri
val existsi : 'a t -> f:(int -> 'a -> bool) -> bool
val for_alli : 'a t -> f:(int -> 'a -> bool) -> bool
val counti : 'a t -> f:(int -> 'a -> bool) -> int
val findi : 'a t -> f:(int -> 'a -> bool) -> (int * 'a) option
val find_mapi : 'a t -> f:(int -> 'a -> 'b option) -> 'b option
val singleton : 'a -> 'a t
val of_list : 'a list -> 'a t
val of_array : 'a array -> 'a t
val init : int -> f:(int -> 'a) -> 'a t
val enqueue : 'a t -> 'a -> unit
val enqueue_all : 'a t -> 'a list -> unit
val dequeue : 'a t -> 'a option
val dequeue_exn : 'a t -> 'a
val peek : 'a t -> 'a option
val peek_exn : 'a t -> 'a
val clear : 'a t -> unit
val copy : 'a t -> 'a t
val map : 'a t -> f:('a -> 'b) -> 'b t
val mapi : 'a t -> f:(int -> 'a -> 'b) -> 'b t
val concat_map : 'a t -> f:('a -> 'b list) -> 'b t
val concat_mapi : 'a t -> f:(int -> 'a -> 'b list) -> 'b t
val filter_map : 'a t -> f:('a -> 'b option) -> 'b t
val filter_mapi : 'a t -> f:(int -> 'a -> 'b option) -> 'b t
val filter : 'a t -> f:('a -> bool) -> 'a t
val filteri : 'a t -> f:(int -> 'a -> bool) -> 'a t
val filter_inplace : 'a t -> f:('a -> bool) -> unit
val filteri_inplace : 'a t -> f:(int -> 'a -> bool) -> unit
val binary_search_segmented : ('a t, 'a) Base.Binary_searchable_intf.binary_search_segmented
val equal : 'a Core_kernel__.Import.Equal.equal -> 'a t Core_kernel__.Import.Equal.equal
val invariant : 'a Base__.Invariant_intf.inv -> 'a t Base__.Invariant_intf.inv
val create : ?capacity:Base.Int.t -> Base.Unit.t -> _ t

Create an empty queue.

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

last t returns the most recently enqueued element in t, if any.

val last_exn : 'a t -> 'a
val blit_transfer : src:'a t -> dst:'a t -> ?len:Base.Int.t -> Base.Unit.t -> Base.Unit.t

Transfers up to len elements from the front of src to the end of dst, removing them from src. It is an error if len < 0.

Aside from a call to set_capacity dst if needed, runs in O(len) time

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

get t i returns the i'th element in t, where the 0'th element is at the front of t and the length t - 1 element is at the back.

val set : 'a t -> Base.Int.t -> 'a -> Base.Unit.t
val capacity : _ t -> Base.Int.t

Returns the current length of the backing array.

val set_capacity : _ t -> Base.Int.t -> Base.Unit.t

set_capacity t c sets the capacity of t's backing array to at least max c (length t). If t's capacity changes, then this involves allocating a new backing array and copying the queue elements over. set_capacity may decrease the capacity of t, if c < capacity t.

module Stable : sig ... end
OCaml

Innovation. Community. Security.