primitive-containers-0.3.1: containers backed by arrays

Safe HaskellNone
LanguageHaskell2010

Data.Map.Lifted.Unlifted

Contents

Synopsis

Documentation

newtype Map k v Source #

A map from keys k to values v.

Constructors

Map (Map Array UnliftedArray k v) 
Instances
(Ord k, PrimUnlifted v) => IsList (Map k v) Source # 
Instance details

Defined in Data.Map.Lifted.Unlifted

Associated Types

type Item (Map k v) :: Type #

Methods

fromList :: [Item (Map k v)] -> Map k v #

fromListN :: Int -> [Item (Map k v)] -> Map k v #

toList :: Map k v -> [Item (Map k v)] #

(Eq k, Eq v, PrimUnlifted v) => Eq (Map k v) Source # 
Instance details

Defined in Data.Map.Lifted.Unlifted

Methods

(==) :: Map k v -> Map k v -> Bool #

(/=) :: Map k v -> Map k v -> Bool #

(Ord k, Ord v, PrimUnlifted v) => Ord (Map k v) Source # 
Instance details

Defined in Data.Map.Lifted.Unlifted

Methods

compare :: Map k v -> Map k v -> Ordering #

(<) :: Map k v -> Map k v -> Bool #

(<=) :: Map k v -> Map k v -> Bool #

(>) :: Map k v -> Map k v -> Bool #

(>=) :: Map k v -> Map k v -> Bool #

max :: Map k v -> Map k v -> Map k v #

min :: Map k v -> Map k v -> Map k v #

(Show k, Show v, PrimUnlifted v) => Show (Map k v) Source # 
Instance details

Defined in Data.Map.Lifted.Unlifted

Methods

showsPrec :: Int -> Map k v -> ShowS #

show :: Map k v -> String #

showList :: [Map k v] -> ShowS #

(Ord k, Semigroup v, PrimUnlifted v) => Semigroup (Map k v) Source # 
Instance details

Defined in Data.Map.Lifted.Unlifted

Methods

(<>) :: Map k v -> Map k v -> Map k v #

sconcat :: NonEmpty (Map k v) -> Map k v #

stimes :: Integral b => b -> Map k v -> Map k v #

(Ord k, Semigroup v, PrimUnlifted v) => Monoid (Map k v) Source # 
Instance details

Defined in Data.Map.Lifted.Unlifted

Methods

mempty :: Map k v #

mappend :: Map k v -> Map k v -> Map k v #

mconcat :: [Map k v] -> Map k v #

type Item (Map k v) Source # 
Instance details

Defined in Data.Map.Lifted.Unlifted

type Item (Map k v) = (k, v)

empty :: Map k v Source #

The empty diet map.

singleton :: PrimUnlifted v => k -> v -> Map k v Source #

O(1) Create a map with a single element.

lookup :: (Ord k, PrimUnlifted v) => k -> Map k v -> Maybe v Source #

O(log n) Lookup the value at a key in the map.

size :: Map k v -> Int Source #

O(1) The number of elements in the map.

map :: (PrimUnlifted v, PrimUnlifted w) => (v -> w) -> Map k v -> Map k w Source #

O(n) Map over the values in the map.

mapMaybe :: (PrimUnlifted v, PrimUnlifted w) => (v -> Maybe w) -> Map k v -> Map k w Source #

O(n) Drop elements for which the predicate returns Nothing.

mapMaybeWithKey :: (PrimUnlifted v, PrimUnlifted w) => (k -> v -> Maybe w) -> Map k v -> Map k w Source #

O(n) Drop elements for which the predicate returns Nothing. The predicate is given access to the key.

appendWithKey :: (Ord k, PrimUnlifted v) => (k -> v -> v -> v) -> Map k v -> Map k v -> Map k v Source #

union :: (Ord k, PrimUnlifted v) => Map k v -> Map k v -> Map k v Source #

O(n+m) The expression (union t1 t2) takes the left-biased union of t1 and t2. It prefers t1 when duplicate keys are encountered.

Folds

foldlWithKey' Source #

Arguments

:: PrimUnlifted v 
=> (b -> k -> v -> b)

reduction

-> b

initial accumulator

-> Map k v

map

-> b 

O(n) Left fold over the keys and values with a strict accumulator.

foldrWithKey' Source #

Arguments

:: PrimUnlifted v 
=> (k -> v -> b -> b)

reduction

-> b

initial accumulator

-> Map k v

map

-> b 

O(n) Right fold over the keys and values with a strict accumulator.

foldMapWithKey' Source #

Arguments

:: (Monoid b, PrimUnlifted v) 
=> (k -> v -> b)

reduction

-> Map k v

map

-> b 

O(n) Fold over the keys and values of the map with a strict monoidal accumulator. This function does not have left and right variants since the associativity required by a monoid instance means that both variants would always produce the same result.

Monadic Folds

foldlWithKeyM' Source #

Arguments

:: (Monad m, PrimUnlifted v) 
=> (b -> k -> v -> m b)

reduction

-> b

initial accumulator

-> Map k v

map

-> m b 

O(n) Left monadic fold over the keys and values of the map. This fold is strict in the accumulator.

foldrWithKeyM' Source #

Arguments

:: (Monad m, PrimUnlifted v) 
=> (k -> v -> b -> m b)

reduction

-> b

initial accumulator

-> Map k v

map

-> m b 

O(n) Right monadic fold over the keys and values of the map. This fold is strict in the accumulator.

foldlMapWithKeyM' Source #

Arguments

:: (Monad m, Monoid b, PrimUnlifted v) 
=> (k -> v -> m b)

reduction

-> Map k v

map

-> m b 

O(n) Monadic left fold over the keys and values of the map with a strict monoidal accumulator. The monoidal accumulator is appended to the left after each reduction.

foldrMapWithKeyM' Source #

Arguments

:: (Monad m, Monoid b, PrimUnlifted v) 
=> (k -> v -> m b)

reduction

-> Map k v

map

-> m b 

O(n) Monadic right fold over the keys and values of the map with a strict monoidal accumulator. The monoidal accumulator is appended to the right after each reduction.

List Conversion

toList :: (Ord k, PrimUnlifted v) => Map k v -> [(k, v)] Source #

O(n) A list of key-value pairs in ascending order.

fromList :: (Ord k, PrimUnlifted v) => [(k, v)] -> Map k v Source #

O(n*log n) Create a map from a list of key-value pairs. If the list contains more than one value for the same key, the last value is retained. If the keys in the argument are in nondescending order, this algorithm runs in O(n) time instead.

fromListAppend :: (Ord k, Semigroup v, PrimUnlifted v) => [(k, v)] -> Map k v Source #

O(n*log n) This function has the same behavior as fromList, but it combines values with the Semigroup instances instead of choosing the last occurrence.

fromListN Source #

Arguments

:: (Ord k, PrimUnlifted v) 
=> Int

expected size of resulting Map

-> [(k, v)]

key-value pairs

-> Map k v 

O(n*log n) This function has the same behavior as fromList regardless of whether or not the expected size is accurate. Additionally, negative sizes are handled correctly. The expected size is used as the size of the initially allocated buffer when building the Map. If the keys in the argument are in nondescending order, this algorithm runs in O(n) time.

fromListAppendN Source #

Arguments

:: (Ord k, Semigroup v, PrimUnlifted v) 
=> Int

expected size of resulting Map

-> [(k, v)]

key-value pairs

-> Map k v 

O(n*log n) This function has the same behavior as fromListN, but it combines values with the Semigroup instances instead of choosing the last occurrence.

fromSet :: PrimUnlifted v => (k -> v) -> Set k -> Map k v Source #

O(n) Build a map from a set. This function is uses the underlying array that backs the set as the array for the keys. It constructs the values by apply the given function to each key.

elems :: Map k v -> UnliftedArray v Source #

O(1) The values in a map. This is a zero-cost operation.