Copyright | (c) Milan Straka 2011 |
---|---|
License | BSD-style |
Maintainer | fox@ucw.cz |
Stability | provisional |
Portability | portable |
Safe Haskell | Safe |
Language | Haskell98 |
Data.HashSet
Description
Persistent Set
based on hashing, which is defined as
dataSet
e =IntMap
(Some e)
is an IntMap
indexed by hash values of elements,
containing a value of Some e
. That contains either one e
or a
with elements of the same hash values.Set
e
The interface of a Set
is a suitable subset of IntSet
and can be used as a drop-in replacement of Set
.
The complexity of operations is determined by the complexities of
IntMap
and Set
operations. See the sources of
Set
to see which operations from containers
package are used.
Synopsis
- data Set a
- type HashSet a = Set a
- (\\) :: Ord a => Set a -> Set a -> Set a
- null :: Set a -> Bool
- size :: Set a -> Int
- member :: (Hashable a, Ord a) => a -> Set a -> Bool
- notMember :: (Hashable a, Ord a) => a -> Set a -> Bool
- isSubsetOf :: Ord a => Set a -> Set a -> Bool
- isProperSubsetOf :: Ord a => Set a -> Set a -> Bool
- empty :: Set a
- singleton :: Hashable a => a -> Set a
- insert :: (Hashable a, Ord a) => a -> Set a -> Set a
- delete :: (Hashable a, Ord a) => a -> Set a -> Set a
- union :: Ord a => Set a -> Set a -> Set a
- unions :: Ord a => [Set a] -> Set a
- difference :: Ord a => Set a -> Set a -> Set a
- intersection :: Ord a => Set a -> Set a -> Set a
- filter :: Ord a => (a -> Bool) -> Set a -> Set a
- partition :: Ord a => (a -> Bool) -> Set a -> (Set a, Set a)
- map :: (Hashable b, Ord b) => (a -> b) -> Set a -> Set b
- fold :: (a -> b -> b) -> b -> Set a -> b
- elems :: Set a -> [a]
- toList :: Set a -> [a]
- fromList :: (Hashable a, Ord a) => [a] -> Set a
Documentation
The abstract type of a Set
. Its interface is a suitable
subset of IntSet
.
Instances
Eq a => Eq (Set a) Source # | |
(Hashable a, Ord a, Data a) => Data (Set a) Source # | |
Defined in Data.HashSet Methods gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Set a -> c (Set a) Source # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c (Set a) Source # toConstr :: Set a -> Constr Source # dataTypeOf :: Set a -> DataType Source # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c (Set a)) Source # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (Set a)) Source # gmapT :: (forall b. Data b => b -> b) -> Set a -> Set a Source # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Set a -> r Source # gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Set a -> r Source # gmapQ :: (forall d. Data d => d -> u) -> Set a -> [u] Source # gmapQi :: Int -> (forall d. Data d => d -> u) -> Set a -> u Source # gmapM :: Monad m => (forall d. Data d => d -> m d) -> Set a -> m (Set a) Source # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Set a -> m (Set a) Source # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Set a -> m (Set a) Source # | |
Ord a => Ord (Set a) Source # | |
Defined in Data.HashSet | |
(Hashable a, Ord a, Read a) => Read (Set a) Source # | |
Show a => Show (Set a) Source # | |
Ord a => Semigroup (Set a) Source # | |
Ord a => Monoid (Set a) Source # | |
NFData a => NFData (Set a) Source # | |
Defined in Data.HashSet |
type HashSet a = Set a Source #
Deprecated: HashSet is deprecated. Please use Set instead.
The HashSet
is a type synonym for Set
for backward compatibility.
It is deprecated and will be removed in furture releases.
Operators
Query
notMember :: (Hashable a, Ord a) => a -> Set a -> Bool Source #
Is the element not a member of the set?
isProperSubsetOf :: Ord a => Set a -> Set a -> Bool Source #
Is this a proper subset? (ie. a subset but not equal).
Construction
insert :: (Hashable a, Ord a) => a -> Set a -> Set a Source #
Add a value to the set. When the value is already an element of the set,
it is replaced by the new one, ie. insert
is left-biased.
delete :: (Hashable a, Ord a) => a -> Set a -> Set a Source #
Delete a value in the set. Returns the original set when the value was not present.
Combine
Filter
filter :: Ord a => (a -> Bool) -> Set a -> Set a Source #
Filter all elements that satisfy some predicate.
partition :: Ord a => (a -> Bool) -> Set a -> (Set a, Set a) Source #
Partition the set according to some predicate. The first set contains all elements that satisfy the predicate, the second all elements that fail the predicate.
Map
map :: (Hashable b, Ord b) => (a -> b) -> Set a -> Set b Source #
is the set obtained by applying map
f sf
to each element of s
.
It's worth noting that the size of the result may be smaller if, for some
(x,y)
, x /= y && f x == f y
Fold
fold :: (a -> b -> b) -> b -> Set a -> b Source #
Fold over the elements of a set in an unspecified order.