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: December 2018
empty
:: Ord a => RedBlackTree a
Return an empty set. |
null
:: RedBlackTree a -> Bool
Test for an empty set. |
elem
:: Ord a => a -> RedBlackTree a -> Bool
Returns true if an element is contained in a set. |
insert
:: Ord a => a -> RedBlackTree a -> RedBlackTree a
Inserts an element into a set if it is not already there. |
delete
:: Ord a => 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
:: Ord a => [a] -> RedBlackTree a
Transforms a list of elements into a set. |
union
:: Ord a => RedBlackTree a -> RedBlackTree a -> RedBlackTree a
Computes the union of two sets. |
intersect
:: Ord a => RedBlackTree a -> RedBlackTree a -> RedBlackTree a
Computes the intersection of two sets. |
disjoint
:: Ord a => 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. |