Module Hashset


module Hashset: sig .. end
Hashsets as a parameterized type using Hashtbl.

type 'a hashset = ('a, unit) Hashtbl.t 
val create : int -> 'a hashset
Set "construction" - really just an alias for Hashtbl.create.
Returns A new (empty) set
n : Desired size
val copy : 'a hashset -> 'a hashset
Set copying.
Returns A mostly-shallow copy of s
s : Set to copy
val clear : 'a hashset -> unit
Remove all elements.
s : Set to clear
val mem : 'a hashset -> 'a -> bool
Set membership.
Returns true if e in s; false otherwise
s : A set
e : An element
val size : 'a hashset -> int
Set size.
Returns The number of elements in s
s : A set
val empty : 'a hashset -> bool
Test for emptiness.
Returns true if s has no elements
s : A set
val iter : ('a -> unit) -> 'a hashset -> unit
Iterate.
f : Function to apply to each element of s
s : A set
exception Exists
val exists : ('a -> bool) -> 'a hashset -> bool
@Return true if s has an element that satisfies predicate f; false otherwise
val fold : ('a -> 'b -> 'b) -> 'a hashset -> 'b -> 'b
Fold.
Returns f e{_n} ( ... (f e{_1} a))
f : Function of type 'e -> 'a -> 'a, where 'e is the element type of s and 'a is the type of an accumulator
s : A set
a : An initial accumulator value
val filter : ('a -> bool) -> 'a hashset -> 'a list
Filter (to list).
Returns A list of elements of s that satisfy f e
f : Function of type 'e -> bool, where 'e is the element type of s.
val split : ('a -> bool) -> 'a hashset -> 'a list * 'a list
Split a set based on a predicate (to a pair of lists)
Returns A pair of lists (s_yes, s_no), where s_yes contains elements for which f e == true, and s_no contains elements for which f e == false.
f : Function of type 'e -> bool, where 'e is the element type
exception EmptySet
val choose : 'a hashset -> 'a
Get an element
Returns An arbirary element from the set; raises EmptySet if no such element exists
val add : 'a hashset -> 'a -> unit
In-place add.
s : A Set
e : Element to add to s
val singleton : 'a -> 'a hashset
Create a set of one element
Returns A set containing just e
e : Element to add
val to_list : 'a hashset -> 'a list
Convert hashset to list
Returns A list that contains all the elements of s
s : A set
val from_list : 'a list -> 'a hashset
Convert list to hashset
Returns A hashset that contains all the elements of s
s : A list
val remove : 'a hashset -> 'a -> unit
In-place removal of an element. Ignored if element is not found.
s : A set
e : An element
val minus : 'a hashset -> 'a hashset -> 'a hashset
Applicative set minus.
Returns lhs \ rhs
lhs : Set to remove from
rhs : Elements to remove
val cup : 'a hashset -> 'a hashset -> 'a hashset
Applicative set union.
Returns s1 union s2
s1 : A set
s2 : Another set
val cap : 'a hashset -> 'a hashset -> 'a hashset
Applicative set intersection.
Returns s1 intersect s2
s1 : A set
s2 : Another set
val eq : 'a hashset -> 'a hashset -> bool
Set equality.
Returns true iff s1 == s2
s1 : A set
s2 : Another set
val unique : 'a list -> 'a list
Filter duplicate elements from a list
Returns l with duplicate entries removed (last instance in l of any equivalence class is preserved)
l : List