Library for a set datatype with an implementation using red-black trees. This module is intended to be used qualified, i.e.,
import qualified Set import Set (Set)
All the operations are based on the primitive ordering on elements
obtained by (==)
and (<)
.
Author: Björn Peemöller
Version: September 2015
empty
:: RedBlackTree a
Return an empty set. |
null
:: RedBlackTree a -> Bool
Test for an empty set. |
elem
:: a -> RedBlackTree a -> Bool
Returns true if an element is contained in a set. |
insert
:: a -> RedBlackTree a -> RedBlackTree a
Inserts an element into a set if it is not already there. |
delete
:: a -> RedBlackTree a -> RedBlackTree a
Delete an element from a set. |
toList
:: RedBlackTree a -> [a]
Transforms a set into an ordered list of its elements. |
fromList
:: [a] -> RedBlackTree a
Transforms a list of elements into a set. |
union
:: RedBlackTree a -> RedBlackTree a -> RedBlackTree a
Computes the union of two sets. |
intersect
:: RedBlackTree a -> RedBlackTree a -> RedBlackTree a
Computes the intersection of two sets. |
disjoint
:: RedBlackTree a -> RedBlackTree a -> Bool
Test for disjointness of sets. |
Type synonym: Set a = RedBlackTree a
Return an empty set. |
Test for an empty set.
|
Returns true if an element is contained in a set.
|
Inserts an element into a set if it is not already there. |
Delete an element from a set. |
Transforms a set into an ordered list of its elements.
|
Transforms a list of elements into a set. |
Computes the union of two sets. |
Computes the intersection of two sets. |
Test for disjointness of sets. |