The HashSetFn functor provides a hash-table-based implementation
of imperative sets parameterized over a Key structure.
Synopsis
signature MONO_HASH_SET
functor HashSetFn (Key : HASH_KEY) : MONO_HASH_SET
Functor Argument Interface
Key : HASH_KEY
Functor Argument Description
Key : HASH_KEY-
A structure that implements the
HASH_KEYsignature, whereKey.hash_keywill be the type of the elements in the hash set.
Interface
structure Key : HASH_KEY
type item = Key.hash_key
type set
val mkEmpty : int -> set
val mkSingleton : item -> set
val mkFromList : item list -> set
val toList : set -> item list
val add : set * item -> unit
val addc : set -> item -> unit
val addList : set * item list -> unit
val subtract : set * item -> unit
val subtractc : set -> item -> unit
val subtractList : set * item list -> unit
val delete : set * item -> bool
val member : set * item -> bool
val isEmpty : set -> bool
val isSubset : (set * set) -> bool
val numItems : set -> int
val map : (item -> item) -> set -> set
val mapPartial : (item -> item option) -> set -> set
val app : (item -> unit) -> set -> unit
val fold : (item * 'b -> 'b) -> 'b -> set -> 'b
val partition : (item -> bool) -> set -> (set * set)
val filter : (item -> bool) -> set -> unit
val exists : (item -> bool) -> set -> bool
val all : (item -> bool) -> set -> bool
val find : (item -> bool) -> set -> item option
val listItems : set -> item list
val without : set * item -> unit
Interface Description
structure Key : HASH_KEY-
This substructure is the argument structure, which defines the type of set elements, and hash and equality functions on the key type.
type item = Key.hash_key-
The type of items in the sets.
type set-
The type of imperative sets of items.
val mkEmpty : int -> set-
mkEmpty ncreates an empty set that has initial space to store at leastnitems. val mkSingleton : item -> set-
mkSingleton itemcreates a set withitemas its only initial element. val mkFromList : item list -> set-
mkFromList itemscreates a set withitemsas its initial elements.
val toList : set -> item list-
toList setreturns a list of the items inset. val add : set * item -> unit-
add (set, item)destructively adds the item to the set. val addc : set -> item -> unit-
addc set itemdestructively adds the item to the set. val addList : set * item list -> unit-
addList (set, items)destructively adds the list of items to the set.
val subtract : set * item -> unit-
subtract (set, item)removes the objectitemfromset; it has no effect ifitemis not inset. val subtractc : set -> item -> unit-
subtractc set itemremoves the objectitemfromset; it has no effect ifitemis not inset. val subtractList : set -> item list -> unit-
subtractList set itemsremoves theitemsfromset. This expression is equivalent toList.app (subtractc set) items val delete : set * item -> bool-
subtract (set, item)removes the objectitemfromset(if present) and returnstrueif the item was removed andfalseif it was not present. val member : set * item -> bool-
member (item, set)returnstrueif, and only if,itemis an element ofset. val isEmpty : set -> bool-
isEmpty setreturns true if, and only if,setis empty. val isSubset : (set * set) -> bool-
isSubset (set1, set2)returns true if, and only if,set1is a subset ofset2(i.e., any element ofset1is an element ofset2). val numItems : set -> int-
numItems setreturns the number of items in theset. val map : (item -> item) -> set -> set-
map f setcreates a new set from the result of applying the functionfto the elements ofset. This expression is equivalent tomkFromList (List.map f (toList set)) val mapPartial : (item -> item option) -> set -> set-
mapPartial f setcreates a new set from the result of applying the partial functionfto the elements ofset. This expression is equivalent tomkFromList (List.mapPartial f (toList set)) val app : (item -> unit) -> set -> unit-
app f setapplies the functionfto the items inset. val fold : (item * 'b -> 'b) -> 'b -> set -> 'b-
foldl f init setfolds the functionfover the items insetusinginitas the initial value. val partition : (item -> bool) -> set -> (set * set)-
partition pred setreturns a pair of disjoint sets(tSet, fSet), where the predicatepredreturns true for every element oftSet,falsefor every element offSet, andsetis the union oftSetandfSet. val filter : (item -> bool) -> set -> unit-
filter pred setremoves any elements of set for which the predicatepredreturns false. val exists : (item -> bool) -> set -> bool-
all pred setreturnstrueif, and only if,pred itemreturns true for all elementsiteminset. Elements are checked in an undefined order. val all : (item -> bool) -> set -> bool-
exists pred setreturnstrueif, and only if, there exists an elementiteminsetsuch thatpred itemreturnstrue. Elements are checked in an undefined order. val find : (item -> bool) -> set -> item option-
find pred setreturnsSOME itemif there exists an objectitemin the set for whichpred itemreturnstrue; otherwiseNONEis returned. Items are tested in an undefined order.