primitive-containers-0.4.1: containers backed by arrays

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 detailsDefined in Data.Set.Unboxed.Internal Associated Typestype Item (Set a) :: Type # MethodsfromList :: [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 detailsDefined 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 detailsDefined in Data.Set.Unboxed.Internal Methodscompare :: 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 detailsDefined in Data.Set.Unboxed.Internal MethodsshowsPrec :: Int -> Set a -> ShowS #show :: Set a -> String #showList :: [Set a] -> ShowS # (Prim a, Ord a) => Semigroup (Set a) Source # Instance detailsDefined 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 detailsDefined in Data.Set.Unboxed.Internal Methodsmempty :: Set a #mappend :: Set a -> Set a -> Set a #mconcat :: [Set a] -> Set a # (Hashable a, Prim a) => Hashable (Set a) Source # Instance detailsDefined in Data.Set.Unboxed.Internal MethodshashWithSalt :: Int -> Set a -> Int #hash :: Set a -> Int # Source # Instance detailsDefined in Data.Set.Unboxed.Internal Associated Typestype Unlifted (Set a) :: TYPE UnliftedRep # MethodstoUnlifted# :: Set a -> Unlifted (Set a) #fromUnlifted# :: Unlifted (Set a) -> Set a #writeUnliftedArray# :: MutableArrayArray# s -> Int# -> Set a -> State# s -> State# s #readUnliftedArray# :: MutableArrayArray# s -> Int# -> State# s -> (#State# s, Set a#) # type Item (Set a) Source # Instance detailsDefined in Data.Set.Unboxed.Internal type Item (Set a) = a type Unlifted (Set a) Source # Instance detailsDefined in Data.Set.Unboxed.Internal type Unlifted (Set a) = ByteArray#

The empty set.

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

Construct a set with a single element.

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

Construct a set with two elements.

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

Construct a set with two elements.

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.

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

Is the first argument a subset of the second argument?

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

Do the two sets contain any of the same elements?

Arguments

 :: (Enum a, Ord a, Num a, Prim a) => a Inclusive lower bound -> a Inclusive upper bound -> Set a

The set that includes all elements from the lower bound to the upper bound.

# 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.

toArray :: Set a -> PrimArray a Source #

O(1) Convert a set to an array. The elements are given in ascending order. This function is zero-cost.

# 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.

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

Map over the elements of a set. The provided function must be monotonic.