|
|
|
|
|
Description |
|
|
Synopsis |
|
|
|
|
Set type
|
|
|
|
|
Operators
|
|
|
O(n+m). See difference.
|
|
Query
|
|
|
O(1). Is this the empty set?
|
|
|
O(1). The number of elements in the set.
|
|
|
O(log n). Is the element in the set?
|
|
|
O(n+m). Is this a subset?
|
|
|
O(n+m). Is this a proper subset? (ie. a subset but not equal).
|
|
Construction
|
|
|
O(1). The empty set.
|
|
|
O(1). Create a singleton set.
|
|
|
O(log n). Insert an element in a set.
|
|
|
O(log n). Delete an element from a set.
|
|
Combine
|
|
|
O(n+m). The union of two sets. Uses the efficient hedge-union algorithm.
|
|
|
The union of a list of sets: (unions == foldl union empty).
|
|
|
O(n+m). Difference of two sets.
The implementation uses an efficient hedge algorithm comparable with hedge-union.
|
|
|
O(n+m). The intersection of two sets.
|
|
Filter
|
|
|
O(n). Filter all elements that satisfy the predicate.
|
|
|
O(n). Partition the set into two sets, one with all elements that satisfy
the predicate and one with all elements that don't satisfy the predicate.
See also split.
|
|
|
O(log n). The expression (split x set) is a pair (set1,set2)
where all elements in set1 are lower than x and all elements in
set2 larger than x.
|
|
|
O(log n). Performs a split but also returns whether the pivot
element was found in the original set.
|
|
Fold
|
|
fold :: (a -> b -> b) -> b -> Set a -> b | Source |
|
O(n). Fold the elements of a set.
|
|
Min/Max
|
|
|
O(log n). The minimal element of a set.
|
|
|
O(log n). The maximal element of a set.
|
|
|
O(log n). Delete the minimal element.
|
|
|
O(log n). Delete the maximal element.
|
|
|
O(log n). Delete and find the minimal element.
|
|
|
O(log n). Delete and find the maximal element.
|
|
Conversion
|
|
List
|
|
|
O(n). The elements of a set.
|
|
|
O(n). Convert the set to a list of elements.
|
|
|
O(n*log n). Create a set from a list of elements.
|
|
Ordered list
|
|
|
O(n). Convert the set to an ascending list of elements.
|
|
|
O(n). Build a map from an ascending list in linear time.
|
|
|
O(n). Build a set from an ascending list of distinct elements in linear time.
|
|
Debugging
|
|
|
O(n). Show the tree that implements the set. The tree is shown
in a compressed, hanging format.
|
|
|
O(n). The expression (showTreeWith hang wide map) shows
the tree that implements the set. If hang is
True, a hanging tree is shown otherwise a rotated tree is shown. If
wide is true, an extra wide version is shown.
Set> putStrLn $ showTreeWith True False $ fromDistinctAscList [1..5]
4
+--2
| +--1
| +--3
+--5
Set> putStrLn $ showTreeWith True True $ fromDistinctAscList [1..5]
4
|
+--2
| |
| +--1
| |
| +--3
|
+--5
Set> putStrLn $ showTreeWith False True $ fromDistinctAscList [1..5]
+--5
|
4
|
| +--3
| |
+--2
|
+--1
|
|
|
O(n). Test if the internal set structure is valid.
|
|
Produced by Haddock version 2.6.0 |