The HashConsSet structure implements finite sets of hash-consed objects.
Synopsis
signature HASH_CONS_SET
structure HashConsSet : HASH_CONS_SET
Interface
type 'a obj = 'a HashCons.obj
type 'a set
val empty : 'a set
val singleton : 'a obj -> 'a set
val fromList : 'a obj list -> 'a set
val add : 'a set * 'a obj -> 'a set
val add' : ('a obj * 'a set) -> 'a set
val addList : 'a set * 'a obj list -> 'a set
val subtract : 'a set * 'a obj -> 'a set
val subtract' : ('a obj * 'a set) -> 'a set
val subtractList : 'a set * 'a obj list -> 'a set
val delete : 'a set * 'a obj -> 'a set
val member : 'a set * 'a obj -> bool
val isEmpty : 'a set -> bool
val equal : ('a set * 'a set) -> bool
val compare : ('a set * 'a set) -> order
val isSubset : ('a set * 'a set) -> bool
val disjoint : 'a set * 'a set -> bool
val numItems : 'a set -> int
val toList : 'a set -> 'a obj list
val listItems : 'a set -> 'a obj list
val union : 'a set * 'a set -> 'a set
val intersection : 'a set * 'a set -> 'a set
val difference : 'a set * 'a set -> 'a set
val map : ('a obj -> 'b obj) -> 'a set -> 'b set
val mapPartial : ('a obj -> 'b obj option) -> 'a set -> 'b set
val app : ('a obj -> unit) -> 'a set -> unit
val foldl : ('a obj * 'b -> 'b) -> 'b -> 'a set -> 'b
val foldr : ('a obj * 'b -> 'b) -> 'b -> 'a set -> 'b
val partition : ('a obj -> bool) -> 'a set -> ('a set * 'a set)
val filter : ('a obj -> bool) -> 'a set -> 'a set
val all : ('a obj -> bool) -> 'a set -> bool
val exists : ('a obj -> bool) -> 'a set -> bool
val find : ('a obj -> bool) -> 'a set -> 'a obj option
Description
type 'a obj = 'a HashCons.obj-
The elements in the set are hash-cons objects.
type 'a set-
A finite set of
'a objvalues. val empty : 'a set-
The empty set.
val singleton : 'a obj -> 'a set-
singleton objcreates a singleton set containingobj. val fromList : 'a obj list -> 'a set-
fromList objscreates a set from the list of objects. val add : 'a set * 'a obj -> 'a set-
add (set, obj)adds the object to the set. val add' : ('a obj * 'a set) -> 'a set-
add' (obj, set)adds the object to the set. val addList : 'a set * 'a obj list -> 'a set-
addList (set, objs)adds the list of objects to the set. val subtract : 'a set * 'a obj -> 'a set-
subtract (set, obj)removes the objectobjfromset. Acts as the identity ifobjis not in the set. val subtract' : ('a obj * 'a set) -> 'a set-
subtract (obj, set)removes the objectobjfromset. Acts as the identity ifobjis not in the set. val delete : 'a set * 'a obj -> 'a set-
delete (set, obj)removes the objectobjfromset. Unlikesubtract, this function raises theNotFoundexception ifobjis not in the set. val member : 'a set * 'a obj -> bool-
member (obj, set)returnstrueif, and only if,objis an element ofset. val isEmpty : 'a set -> bool-
isEmpty setreturns true if, and only if,setis empty. val equal : ('a set * 'a set) -> bool-
equal (set1, set2)returns true if, and only if, the two sets are equal (i.e., they contain the same elements). val compare : ('a set * 'a set) -> order-
compare (set1, set2)returns the lexical order of the two sets. val isSubset : ('a set * 'a set) -> bool-
isSubset (set1, set2)returns true if, and only if,set1is a subset ofset2(i.e., any element ofset1is an element ofset2). val disjoint : 'a set * 'a set -> bool-
equal (set1, set2)returns true if, and only if, the two sets are disjoint (i.e., their intersection is empty). val numItems : 'a set -> int-
numItems setreturns the number of items in theset.
val toList : 'a set -> 'a obj list-
toList setreturns a list of the objects inset. val union : 'a set * 'a set -> 'a set-
union (set1, set2)returns the union of the two sets. val intersection : 'a set * 'a set -> 'a set-
intersection (set1, set2)returns the intersection of the two sets. val difference : 'a set * 'a set -> 'a set-
difference (set1, set2)returns the difference of the two sets; i.e., the set of objects that are inset1, but not inset2. val map : ('a obj -> 'b obj) -> 'a set -> 'b set-
map f setconstructs a new set from the result of applying the functionfto the elements ofset. This expression is equivalent tofromList (List.map f (toList set)) val mapPartial : ('a obj -> 'b obj option) -> 'a set -> 'b set-
mapPartial f setconstructs a new set from the result of applying the functionfto the elements ofset. This expression is equivalent tofromList (List.mapPartial f (toList set)) val app : ('a obj -> unit) -> 'a set -> unit-
app f setapplies the functionfto the objects inset. This expression is equivalent toList.app f (toList set)
val fold : ('a obj * 'b -> 'b) -> 'b -> 'a set -> 'b-
fold f init setfolds the functionfover the objects insetusinginitas the initial value. This expression is equivalent toList.foldl f init (toList set)Although the order in which the elements are processed is unspecified.
val partition : ('a obj -> bool) -> 'a set -> ('a set * 'a 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 : ('a obj -> bool) -> 'a set -> 'a set-
filter pred setfilters out any elements of set for which the predicatepredreturns false. This expression is equivalent to#1 (partition pred set) val all : ('a obj -> bool) -> 'a set -> bool-
all pred setreturnstrueif, and only if,pred objreturns true for all elementsobjinset. val exists : ('a obj -> bool) -> 'a set -> bool-
exists pred setreturnstrueif, and only if, there exists an elementobjinsetsuch thatpred objreturnstrue. val find : ('a obj -> bool) -> 'a set -> 'a obj option-
find pred setreturnsSOME objif there exists an objectobjin the set for whichpred objreturnstrue; otherwiseNONEis returned.