The IntervalSetFn functor provides sets over a discrete ordered domain,
where the sets are represented by intervals. It is meant for representing
dense sets (e.g., unicode character classes).
Synopsis
signature INTERVAL_SET
functor IntervalSetFn (D : INTERVAL_DOMAIN) : INTERVAL_SET
Functor Argument Description
D : INTERVAL_DOMAIN-
The argument defines the type of points in the domain and their order structure.
Interface
structure D : INTERVAL_DOMAIN
type item = D.point
type interval = (item * item)
type set
val empty : set
val universe : set
val singleton : item -> set
val interval : item * item -> set
val isEmpty : set -> bool
val isUniverse : set -> bool
val member : set * item -> bool
val items : set -> item list
val intervals : set -> interval list
val add : set * item -> set
val add' : item * set -> set
val addInt : set * interval -> set
val addInt' : interval * set -> set
val complement : set -> set
val union : (set * set) -> set
val intersect : (set * set) -> set
val difference : (set * set) -> set
val app : (item -> unit) -> set -> unit
val foldl : (item * 'a -> 'a) -> 'a -> set -> 'a
val foldr : (item * 'a -> 'a) -> 'a -> set -> 'a
val filter : (item -> bool) -> set -> set
val exists : (item -> bool) -> set -> bool
val all : (item -> bool) -> set -> bool
val appInt : (interval -> unit) -> set -> unit
val foldlInt : (interval * 'a -> 'a) -> 'a -> set -> 'a
val foldrInt : (interval * 'a -> 'a) -> 'a -> set -> 'a
val filterInt : (interval -> bool) -> set -> set
val existsInt : (interval -> bool) -> set -> bool
val allInt : (interval -> bool) -> set -> bool
val compare : set * set -> order
val isSubset : set * set -> bool
Interface Description
structure D : INTERVAL_DOMAIN-
The argument structure.
type item = D.point-
The type of items in the set.
type interval = (item * item)-
A collection of items defined by an interval.
type set-
The type of a set of items.
val empty : set-
The empty set.
val universe : set-
The set of all elements in the domain, which is specified as the interval
(D.minPt, D.maxPt). val singleton : item -> set-
singleton itemreturns the singleton set containingitem. val fromList : item list -> set-
fromList itemsreturns the set containing the list of items. val interval : item * item -> set-
singleton (pt1, pt2)returns a set containing the items between the itemspt1andpt2(as ordered byD.compare). This expression raises theDomainexception ifD.compare(pt1, pt2) = GREATER. val isEmpty : set -> bool-
isEmpty setreturnstrueif, and only if,setis empty. val isUniverse : set -> bool-
isUniverse setreturnstrueif, and only if,setcontains all of the elements of the domain. val member : set * item -> bool-
isEmpty (set, item)returnstrueif, and only if,itemis contained inset.
val toList : set -> item list-
toList setreturns a list of the items inset. The items will be sorted in increasing order. val intervals : set -> interval list-
intervals setreturns a list of disjoint intervals that represents the set. The intervals will be sorted in increasing order. val add : set * item -> set-
add (set, item)addsitemtosetand returns the resulting set. val add' : item * set -> set-
add' (item, set)addsitemtosetand returns the resulting set.(* add an interval to the set *)
val addInt : set * interval -> set-
addInt (set, (pt1, pt2))adds the items between the itemspt1andpt2(as ordered byD.compare) toset. This expression raises theDomainexception ifD.compare(pt1, pt2) = GREATER. val addInt' : interval * set -> set-
addInt' ((pt1, pt2), set)adds the items between the itemspt1andpt2(as ordered byD.compare) toset. This expression raises theDomainexception ifD.compare(pt1, pt2) = GREATER. val complement : set -> set-
complement setreturns the complement ofset(i.e., the set of items from the universe that are not inset). val union : (set * set) -> set-
union (set1, set2)returns the union ofset1andset2; (i.e., the set of items that are inset1or inset2). val intersect : (set * set) -> set-
intersect (set1, set2)returns the intersection ofset1andset2; (i.e., the set of items that are in bothset1and`set2`). val difference : (set * set) -> set-
difference (set1, set2)returns the set difference ofset1andset2; (i.e., the set of items that are inset1, but not inset2). val app : (item -> unit) -> set -> unit-
app f setapplies the functionfto the items inset. This expression is equivalent toList.app f (toList set) val foldl : (item * 'a -> 'a) -> 'a -> set -> 'a-
foldl f init setfolds the functionfover the items insetin increasing order usinginitas the initial value. This expression is equivalent toList.foldl f init (toList set) val foldr : (item * 'a -> 'a) -> 'a -> set -> 'a-
foldr f init setfolds the functionfover the items insetin decreasing order usinginitas the initial value. This expression is equivalent toList.foldr f init (toList set) val filter : (item -> bool) -> set -> set-
filter pred setfilters out any items of set for which the predicatepredreturns false. val exists : (item -> bool) -> set -> bool-
exists pred setreturnstrueif, and only if, there is an item in the set for whichpredreturnstrue. This function short-circuits evaluation once an item is encountered for whichpredreturnstrue. val all : (item -> bool) -> set -> bool-
all pred setreturnstrueif, and only if,predreturnstruefor all items in the set. This function short-circuits evaluation once an item is encountered for whichpredreturnsfalse. val appInt : (interval -> unit) -> set -> unit-
appInt f setapplies the functionfto the intervals inset. This expression is equivalent toList.app f (intervals set) val foldlInt : (interval * 'a -> 'a) -> 'a -> set -> 'a-
foldlInt f init setfolds the functionfover the intervals insetin increasing order usinginitas the initial value. This expression is equivalent toList.foldl f init (intervals set) val foldrInt : (interval * 'a -> 'a) -> 'a -> set -> 'a-
foldrInt f init setfolds the functionfover the intervals insetin decreasing order usinginitas the initial value. This expression is equivalent toList.foldr f init (intervals set) val filterInt : (interval -> bool) -> set -> set-
filterInt pred setfilters out any intervals of set for which the predicatepredreturns false. val existsInt : (interval -> bool) -> set -> bool-
existsInt pred setreturnstrueif, and only if, there is an interval in the set for whichpredreturnstrue. This function short-circuits evaluation once an interval is encountered for whichpredreturnstrue. val allInt : (interval -> bool) -> set -> bool-
allInt pred setreturnstrueif, and only if,predreturnstruefor all of the intervals in the set. This function short-circuits evaluation once an interval is encountered for whichpredreturnsfalse. val compare : set * set -> order-
compare (set1, set2)returns the lexical order of the two sets. 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).
Deprecated functions
The following functions are part of the interface, but have been deprecated.
val items : set -> item list`-
Use
toListinstead.