Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Representation of a structure containing unique elements. The internal structure is an AVL tree.
Synopsis
- data Set a
- difference :: Ord a => Set a -> Set a -> Set a
- intersection :: Ord a => Set a -> Set a -> Set a
- union :: Ord a => Set a -> Set a -> Set a
- empty :: Set a
- fromList :: Ord a => [a] -> Set a
- singleton :: a -> Set a
- toAscList :: Set a -> [a]
- toDescList :: Set a -> [a]
- delete :: Ord a => a -> Set a -> Set a
- filter :: Ord a => (a -> Bool) -> Set a -> Set a
- insert :: Ord a => a -> Set a -> Set a
- isSubsetOf :: Ord a => Set a -> Set a -> Bool
- lookupMax :: Set a -> Maybe a
- lookupMin :: Set a -> Maybe a
- member :: Ord a => a -> Set a -> Bool
- null :: Set a -> Bool
- size :: Set a -> Int
- valid :: Ord a => Set a -> Bool
Type
A set containing elements of type a.
The internal structure is an AVL tree; a tree that is always height-balanced (the absolute value of the level difference between the left and right subtrees is at most 1).
Instances
Foldable Set Source # | |
Defined in Mini.Data.Set fold :: Monoid m => Set m -> m # foldMap :: Monoid m => (a -> m) -> Set a -> m # foldMap' :: Monoid m => (a -> m) -> Set a -> m # foldr :: (a -> b -> b) -> b -> Set a -> b # foldr' :: (a -> b -> b) -> b -> Set a -> b # foldl :: (b -> a -> b) -> b -> Set a -> b # foldl' :: (b -> a -> b) -> b -> Set a -> b # foldr1 :: (a -> a -> a) -> Set a -> a # foldl1 :: (a -> a -> a) -> Set a -> a # elem :: Eq a => a -> Set a -> Bool # maximum :: Ord a => Set a -> a # | |
Show a => Show (Set a) Source # | |
Eq a => Eq (Set a) Source # | |
Ord a => Ord (Set a) Source # | |
Combination
Construction
fromList :: Ord a => [a] -> Set a Source #
\(O(n \log n)\) From a tail-biased list of elements to a set containing the elements
Conversion
toDescList :: Set a -> [a] Source #
\(O(n)\) From a set to a list of elements in descending order
Modification
delete :: Ord a => a -> Set a -> Set a Source #
\(O(\log n)\) From an element and a set to the set without the element
filter :: Ord a => (a -> Bool) -> Set a -> Set a Source #
\(O(n)\) From a predicate and a set to the set with elements satisfying the predicate
insert :: Ord a => a -> Set a -> Set a Source #
\(O(\log n)\) From an element and a set to the set including the element
Query
isSubsetOf :: Ord a => Set a -> Set a -> Bool Source #
\(O(n \log n)\) From a set and another set to whether the former is a subset of the latter
member :: Ord a => a -> Set a -> Bool Source #
\(O(\log n)\) From an element and a set to whether the element is in the set