The HashSetFn functor provides an imperative, hash-table-based
implementation of 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 add' : item * set -> unit
val addc : set -> item -> unit
val addList : set * item list -> unit
val addSet : set * set -> unit
val subtract : set * item -> unit
val subtract' : item * set -> unit
val subtractc : set -> item -> unit
val subtractList : set * item list -> unit
val subtractSet : set * set -> unit
val delete : set * item -> bool
val member : set * item -> bool
val isEmpty : set -> bool
val isSubset : (set * set) -> bool
val disjoint : set * set -> bool
val numItems : set -> int
val union : set * set -> set
val intersection : set * set -> set
val difference : set * set -> set
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 add' : item * set -> unit-
add (item, set)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 addSet : set * set -> unit-
addSet (set1, set2)destructively adds the items ofset2toset1.
val subtract : set * item -> unit-
subtract (set, item)removes the objectitemfromset; it has no effect ifitemis not inset. val subtract' : item * set -> unit-
subtract (item, set)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, items)removes theitemsfromset. This expression is equivalent toList.app (subtractc set) items val subtractSet : set * set -> unit-
subtractSet (set1, set2)removes theitemsthat are inset2fromset1. 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 disjoint : (set * set) -> bool-
isSubset (set1, set2)returns true if, and only if, the two sets are disjoint. 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 union : set * set -> set-
union (set1, set2)returns a new set that is the union of the two sets. val intersection : set * set -> set-
intersection (set1, set2)returns a new set that is the intersection of the two sets. val difference : set * set -> set-
difference (set1, set2)returns a new set that is the difference of the two sets; i.e., the set of items that are inset1, but not inset2. 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.