package pomap

  1. Overview
  2. Docs

Module Make.StoreSource

Store module used to store nodes of the partially ordered map.

Index module used to index elements in the store

Sourcetype +'a t

Type of stores

Sourceval empty : 'a t

The empty store

Sourceval is_empty : 'a t -> bool

is_empty s

  • returns

    true if s is empty, false otherwise.

Sourceval cardinal : 'a t -> int

cardinal s

  • returns

    the number of elements in s.

Sourceval next_ix : 'a t -> Ix.t

next_ix s

  • returns

    the next index the store s will use to index a new element.

Sourceval singleton : 'a -> Ix.t * 'a t

singleton el

  • returns

    the tuple (ix, store), where ix is the index under which the only element el was stored, and store is the store containing el.

Sourceval add : 'a -> 'a t -> Ix.t * 'a t

add el s

  • returns

    the tuple (new_ix, new_store), where new_ix is the index under which the new element el was stored, and new_store is the new store containing el.

Sourceval find : Ix.t -> 'a t -> 'a

find ix s

  • returns

    the element stored under index ix.

Sourceval update : Ix.t -> 'a -> 'a t -> 'a t

update ix el s rebinds index ix in store s to point to el, and returns the resulting store. The previous binding disappears. New indices resulting from further adds are guaranteed to have higher indices.

Sourceval remove : Ix.t -> 'a t -> 'a t

remove ix s removes the binding of index ix of store s, and returns the resulting store.

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

iter f s applies f to all stored elements in store s. The order in which elements are passed to f is unspecified.

Sourceval iteri : (Ix.t -> 'a -> unit) -> 'a t -> unit

iter f s applies f to all indexes and their related elements in store s. The order in which elements are passed to f is unspecified.

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

map f s

  • returns

    a store with all elements in s mapped from their original value to the codomain of f. Only the elements are passed to f. The order in which elements are passed to f is unspecified.

Sourceval mapi : (Ix.t -> 'a -> 'b) -> 'a t -> 'b t

mapi f s same as map, but function f also receives the index associated with the elements.

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

fold f s a computes (f eN ... (f e1 a) ...), where e1 ... eN are the elements of all bindings in store s. The order in which the bindings are presented to f is unspecified.

Sourceval foldi : (Ix.t -> 'a -> 'b -> 'b) -> 'a t -> 'b -> 'b

foldi f s a same as fold, but function f also receives the index associated with the elements.

Sourceval to_list : 'a t -> (Ix.t * 'a) list

to_list s converts s to an association list of indices and elements.

Sourceval choose : 'a t -> Ix.t * 'a

choose s

  • returns

    a tuple (ix, x), where ix is the index of some unspecified value x in store s.

Sourceval filter : (Ix.t -> 'a -> bool) -> 'a t -> 'a t

filter p s

  • returns

    the store of all elements in s that satisfy p.

Sourceval partition : (Ix.t -> 'a -> bool) -> 'a t -> 'a t * 'a t

partition p s

  • returns

    a pair of stores (s1, s2), where s1 is the store of all the elements of s that satisfy the predicate p, and s2 is the store of all the elements of s that do not satisfy p.

Sourceval eq_classes : ('a -> 'a -> bool) -> 'a t -> ('a * 'a t) list

eq_classes eq s

  • returns

    a list of tuples (el, ec), where el is the only kind of element as identified by the equivalence relation eq stored in the equivalence class (store) ec under each index. Every such equivalence class is unique and maximal with respect to s, and the original indices of the elements are preserved in each class.

Sourceval get_ix_map : 'a t -> 'a Ix.Map.t

get_ix_map s

  • returns

    a map of all indices mapped to their respective elements in store s.

OCaml

Innovation. Community. Security.