primitive-containers-0.3.0: containers backed by arrays

Safe HaskellNone
LanguageHaskell2010

Data.Set.Unboxed

Contents

Synopsis

Documentation

data Set a Source #

A set of elements.

Instances
(Prim a, Ord a) => IsList (Set a) Source #

The functions that convert a list to a Set are asymptotically better that using foldMap singleton, with a cost of O(n*log n) rather than O(n^2). If the input list is sorted, even if duplicate elements are present, the algorithm further improves to O(n). The fastest option available is calling fromListN on a presorted list and passing the correct size size of the resulting Set. However, even if an incorrect size is given to this function, it will still correctly convert the list into a Set.

Instance details

Defined in Data.Set.Unboxed.Internal

Associated Types

type Item (Set a) :: * #

Methods

fromList :: [Item (Set a)] -> Set a #

fromListN :: Int -> [Item (Set a)] -> Set a #

toList :: Set a -> [Item (Set a)] #

(Prim a, Eq a) => Eq (Set a) Source # 
Instance details

Defined in Data.Set.Unboxed.Internal

Methods

(==) :: Set a -> Set a -> Bool #

(/=) :: Set a -> Set a -> Bool #

(Prim a, Ord a) => Ord (Set a) Source # 
Instance details

Defined in Data.Set.Unboxed.Internal

Methods

compare :: Set a -> Set a -> Ordering #

(<) :: Set a -> Set a -> Bool #

(<=) :: Set a -> Set a -> Bool #

(>) :: Set a -> Set a -> Bool #

(>=) :: Set a -> Set a -> Bool #

max :: Set a -> Set a -> Set a #

min :: Set a -> Set a -> Set a #

(Prim a, Show a) => Show (Set a) Source # 
Instance details

Defined in Data.Set.Unboxed.Internal

Methods

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

show :: Set a -> String #

showList :: [Set a] -> ShowS #

(Prim a, Ord a) => Semigroup (Set a) Source # 
Instance details

Defined in Data.Set.Unboxed.Internal

Methods

(<>) :: Set a -> Set a -> Set a #

sconcat :: NonEmpty (Set a) -> Set a #

stimes :: Integral b => b -> Set a -> Set a #

(Prim a, Ord a) => Monoid (Set a) Source # 
Instance details

Defined in Data.Set.Unboxed.Internal

Methods

mempty :: Set a #

mappend :: Set a -> Set a -> Set a #

mconcat :: [Set a] -> Set a #

(Hashable a, Prim a) => Hashable (Set a) Source # 
Instance details

Defined in Data.Set.Unboxed.Internal

Methods

hashWithSalt :: Int -> Set a -> Int #

hash :: Set a -> Int #

PrimUnlifted (Set a) Source # 
Instance details

Defined in Data.Set.Unboxed.Internal

type Item (Set a) Source # 
Instance details

Defined in Data.Set.Unboxed.Internal

type Item (Set a) = a

empty :: Set a Source #

The empty set.

singleton :: Prim a => a -> Set a Source #

Construct a set with a single element.

null :: Set a -> Bool Source #

O(1) Is the set empty?

member :: (Prim a, Ord a) => a -> Set a -> Bool Source #

Test whether or not an element is present in a set.

size :: Prim a => Set a -> Int Source #

The number of elements in the set.

difference :: (Ord a, Prim a) => Set a -> Set a -> Set a Source #

The difference of two sets.

(\\) :: (Ord a, Prim a) => Set a -> Set a -> Set a Source #

Infix operator for difference.

intersection :: (Ord a, Prim a) => Set a -> Set a -> Set a Source #

The intersection of two sets.

List Conversion

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

Convert a set to a list. The elements are given in ascending order.

fromList :: (Ord a, Prim a) => [a] -> Set a Source #

Convert a list to a set.

Folds

foldr :: Prim a => (a -> b -> b) -> b -> Set a -> b Source #

Right fold over the elements in the set. This is lazy in the accumulator.

foldMap :: (Monoid m, Prim a) => (a -> m) -> Set a -> m Source #

Lazy monoidal fold over the elements in the set.

foldl' :: Prim a => (b -> a -> b) -> b -> Set a -> b Source #

Strict left fold over the elements in the set.

foldr' :: Prim a => (a -> b -> b) -> b -> Set a -> b Source #

Strict right fold over the elements in the set.

foldMap' :: (Monoid m, Prim a) => (a -> m) -> Set a -> m Source #

Strict monoidal fold over the elements in the set.

Traversals

traverse_ :: (Applicative m, Prim a) => (a -> m b) -> Set a -> m () Source #

Traverse a set, discarding the result.

itraverse_ :: (Applicative m, Prim a) => (Int -> a -> m b) -> Set a -> m () Source #

Traverse a set with the indices, discarding the result.