package ringo

  1. Overview
  2. Docs

SingletonSey(H) is a set module but it only supports singleton sets: sets with at most one element.

The create function is replaced to take a () parameter because the size is hardcoded.

Note that all policies are equivalent in the case of a singleton set. This is why the singleton set does not require the user to specify any policy.

Parameters

Signature

type elt = H.t

The type of values held by the cache.

type t

The type of caches holding values of type elt.

val add : t -> elt -> unit

add c v adds the value v to the cache c. This may or may not cause another element to be removed from the cache, depending on the number of elements already present in the cache c, the size-bound of the cache c, and the policy of the cache c towards its size-bound.

Note that after the add c v call returns, v is the most recent element in the cache. This is true whether or not the element was already in the cache before the call. This is true for whichever replacement policy (see Ringo.replacement) the cache has.

If v is already present in c, and the accounting policy of the cache is Sloppy, the element may or may not count twice towards the size bound for some time. On the other hand, if the cache accounting is Precise then the element v only counts once. See Ringo.accounting for more details.

val fold : (elt -> 'a -> 'a) -> t -> 'a -> 'a

fold f c init folds the function f and value init over the elements of c.

Note that for caches with a Weak overflow policy, this function may fold over a subset of the elements of c. See Ringo (or Functors) for more details.

val mem : t -> elt -> bool

mem c v is true if v is present in c. It is false otherwise.

Note that the in caches with a non-FIFO replacement policy, this may have a side effect on the v element. Specifically, in those caches, it might make it less likely to be removed when supernumerary elements are inserted.

val remove : t -> elt -> unit

remove c v removes the element v from c. If v is not present in c, it does nothing.

Note that in caches with a Sloppy accounting policy, removed elements can still count towards the size bound for some time. On the other hand, if the cache's accounting policy is Precise then the element immediately stops counting towards the size bound.

val filter : t -> (elt -> bool) -> unit

filter c f removes all the elements v such that f v = true.

Note that in caches with a Sloppy accounting policy, removed elements can still count towards the size bound for some time.

val length : t -> int

length c is the number of elements present in c.

val capacity : t -> int

capacity c is the number of bindings c can hold: capacity (create n) = n

val clear : t -> unit

clear c removes all elements from c.

val create : unit -> t
OCaml

Innovation. Community. Security.