package cpm

  1. Overview
  2. Docs
type 'a t
val create : int -> 'a t

create n creates a 'a TopKeeper.t that will keep up to n best scoring elements. n must be greater than 0.

val add : 'a t -> float -> 'a -> unit

add t score elt add elt with score to the top_keeper t (if the score is good enough or if the top_keeper doesn't hold enough elements yet)

val high_scores_first : 'a t -> (float * 'a) list

high_scores_first t retrieve the n best scores from t (with associated elements); scores are in decreasing order

val get_min_score : 'a t -> float

get_min_score t return the current minimum score in t

val get_curr_size : 'a t -> int

get_curr_size t return the current number of elements in t. Note that get_curr_size t <= get_max_size t is always true (it is the data-structure invariant).

val get_max_size : 'a t -> int

get_max_size t return the number of elements chosen at creation time

OCaml

Innovation. Community. Security.