Safe HaskellSafe

Set

Description

Sets as Binary Search Trees

Synopsis

Documentation

data Set a Source #

Sets are represented by binary trees, where we assume the invariant that the underlying tree is a binary search tree.

Instances

(Ord a, Show a) => Show (Set a) # 

Methods

showsPrec :: Int -> Set a -> ShowS #

show :: Set a -> String #

showList :: [Set a] -> ShowS #

empty :: Set a Source #

The empty set.

insert :: Ord a => a -> Set a -> Set a Source #

Inserting single elements into Sets.

mem :: Ord a => a -> Set a -> Bool Source #

Checking for set membership.

union :: Ord a => Set a -> Set a -> Set a Source #

The union of two Sets.

diff :: Ord a => Set a -> Set a -> Set a Source #

The difference between two Sets.

toList :: Set a -> [a] Source #

Obtain the list representation of a binary search tree (which is a sorted list).