Safe Haskell | None |
---|---|
Language | Haskell2010 |
Data.Set.Unique
Description
This module provides a uniquely-represented Set type.
Uniquely represented sets means that elements inserted in any order are represented by the same set. This makes it useful for type-level programming, and some security applications.
- newtype Set a = Set {}
- fromList :: Ord a => [a] -> Set a
- fromListBy :: (a -> a -> Ordering) -> [a] -> Set a
- empty :: Set a
- singleton :: a -> Set a
- fromDistinctAscList :: [a] -> Set a
- type Builder a b c = Int -> Int -> (Builder a (Braun a) -> Builder (Braun a) b -> c) -> c
- consB :: a -> Builder a c d -> Builder a c d
- nilB :: Builder a b c
- runB :: Builder a (Braun (Braun a)) (Set a) -> Set a
- insert :: Ord a => a -> Set a -> Set a
- insertBy :: (a -> a -> Ordering) -> a -> Set a -> Set a
- delete :: Ord a => a -> Set a -> Set a
- deleteBy :: (a -> a -> Ordering) -> a -> Set a -> Set a
- lookupBy :: (a -> a -> Ordering) -> a -> Set a -> Maybe a
- member :: Ord a => a -> Set a -> Bool
- szfn :: Int -> Int
Set type
A uniquely-represented set.
Instances
Functor Set Source # | |
Foldable Set Source # |
toList (fromDistinctAscList xs) === xs |
Traversable Set Source # | |
Eq a => Eq (Set a) Source # | |
Data a => Data (Set a) Source # | |
Ord a => Ord (Set a) Source # | |
Read a => Read (Set a) Source # | |
Show a => Show (Set a) Source # | |
Generic (Set a) Source # | |
NFData a => NFData (Set a) Source # | |
Generic1 * Set Source # | |
type Rep (Set a) Source # | |
type Rep1 * Set Source # | |
Construction
fromListBy :: (a -> a -> Ordering) -> [a] -> Set a Source #
O(n log n). Create a set from a list, using the supplied ordering function.
fromListBy compare xs === fromList xs
fromDistinctAscList :: [a] -> Set a Source #
O(n). Create a set from a list of ordered, distinct elements.
fromDistinctAscList (toList xs) === xs
Building
consB :: a -> Builder a c d -> Builder a c d Source #
O(1). Push an element to the front of a Builder
.
Modification
insert :: Ord a => a -> Set a -> Set a Source #
sqrt(n log n). Insert an element into the set.
>>>
toList (foldr insert empty [3,1,2,5,4,3,6])
[1,2,3,4,5,6]
insertBy :: (a -> a -> Ordering) -> a -> Set a -> Set a Source #
sqrt(n log n). Insert an element into the set, using the supplied ordering function.
insert x xs === insertBy compare x xs
deleteBy :: (a -> a -> Ordering) -> a -> Set a -> Set a Source #
sqrt(n log n). Delete an element from the set, using the supplied ordering function.
delete x xs === deleteBy compare x xs
Querying
lookupBy :: (a -> a -> Ordering) -> a -> Set a -> Maybe a Source #
O(log^2 n). Lookup an element according to the supplied ordering function in the set.
member :: Ord a => a -> Set a -> Bool Source #
O(log^2 n). Find if an element is a member of the set.