package extlib

  1. Overview
  2. Docs
A complete yet small extension for OCaml standard library

Install

Dune Dependency

Authors

Maintainers

Sources

extlib-1.8.0.tar.gz
md5=43fb3bf2989671af1769147b1171d080
sha512=dedd2bb4a63f2df9e451dbe6aede18d873489a8675f48ded09131f2af4d00dbeaecc8750039b2e4facb9f5f9b1b01c6b7accd392bf8ac5a3f2c801562ce5c4ee

doc/extlib/RefList/index.html

Module RefListSource

Reference on lists.

RefList is a extended set of functions that manipulate list references.

Sourceexception Empty_list
Sourceexception Invalid_index of int
Sourcetype 'a t
Sourceval empty : unit -> 'a t

Returns a new empty ref list

Sourceval is_empty : 'a t -> bool

Return true if a ref list is empty

Sourceval clear : 'a t -> unit

Removes all elements

Sourceval length : 'a t -> int

Returns the number of elements - O(n)

Sourceval copy : dst:'a t -> src:'a t -> unit

Makes a copy of a ref list - O(1)

Sourceval copy_list : dst:'a t -> src:'a list -> unit

Makes a copy of a list - O(1)

Sourceval copy_enum : dst:'a t -> src:'a Enum.t -> unit

Makes a copy of a enum

Sourceval of_list : 'a list -> 'a t

Creates a ref list from a list - O(1)

Sourceval to_list : 'a t -> 'a list

Returns the current elements as a list - O(1)

Sourceval of_enum : 'a Enum.t -> 'a t

Creates a ref list from an enumeration

Sourceval enum : 'a t -> 'a Enum.t

Returns an enumeration of current elements in the ref list

Sourceval add : 'a t -> 'a -> unit

Adds an element at the end - O(n)

Sourceval push : 'a t -> 'a -> unit

Adds an element at the head - O(1)

Sourceval add_sort : ?cmp:('a -> 'a -> int) -> 'a t -> 'a -> unit

Adds an element in a sorted list, using optional comparator or 'compare' as default.

Sourceval first : 'a t -> 'a

Returns the first element or raises Empty_list if the ref list is empty

Sourceval last : 'a t -> 'a

Returns the last element - O(n) or raises Empty_list if the ref list is empty

Sourceval pop : 'a t -> 'a

Removes and returns the first element or raises Empty_list if the ref list is empty

Sourceval npop : 'a t -> int -> 'a list

Removes and returns the n first elements or raises Empty_list if the ref list does not contain enough elements

Sourceval hd : 'a t -> 'a

same as first

Sourceval tl : 'a t -> 'a t

Returns a ref list containing the same elements but without the first one or raises Empty_list if the ref list is empty

Sourceval rev : 'a t -> unit

Reverses the ref list - O(n)

Functional Operations
Sourceval iter : ('a -> unit) -> 'a t -> unit

Apply the given function to all elements of the ref list, in respect with the order of the list

Sourceval find : ('a -> bool) -> 'a t -> 'a

Find the first element matching the specified predicate raise Not_found if no element is found

Sourceval rfind : ('a -> bool) -> 'a t -> 'a

Find the first element in the reversed ref list matching the specified predicate raise Not_found if no element is found

Sourceval find_exc : ('a -> bool) -> exn -> 'a t -> 'a

Same as find but takes an exception to be raised when no element is found as additional parameter

Sourceval exists : ('a -> bool) -> 'a t -> bool

Return true if an element matches the specified predicate

Sourceval for_all : ('a -> bool) -> 'a t -> bool

Return true if all elements match the specified predicate

Sourceval map : ('a -> 'b) -> 'a t -> 'b t

Apply a function to all elements and return the ref list constructed with the function returned values

Sourceval transform : ('a -> 'a) -> 'a t -> unit

transform all elements in the ref list using a function.

Sourceval map_list : ('a -> 'b) -> 'a t -> 'b list

Apply a function to all elements and return the list constructed with the function returned values

Sourceval sort : ?cmp:('a -> 'a -> int) -> 'a t -> unit

Sort elements using the specified comparator or compare as default comparator

Sourceval filter : ('a -> bool) -> 'a t -> unit

Remove all elements that do not match the specified predicate

Sourceval remove : 'a t -> 'a -> unit

Remove an element from the ref list raise Not_found if the element is not found

Sourceval remove_if : ('a -> bool) -> 'a t -> unit

Remove the first element matching the specified predicate raise Not_found if no element has been removed

Sourceval remove_all : 'a t -> 'a -> unit

Remove all elements equal to the specified element from the ref list

Sourcemodule Index : sig ... end

Functions that operate on the ith element of a list.

OCaml

Innovation. Community. Security.