total-maps-1.0.0.3: Dense and sparse total maps.

LicenseMIT
MaintainerPaweł Nowak <pawel834@gmail.com>
Portabilityportable
Safe HaskellNone
LanguageHaskell2010

Data.Total.Array

Description

Bounded, dense, total map implemented as a vector.

Synopsis

Documentation

newtype TotalArray k a Source #

A total map from keys k to values a, represented as an immutable vector.

Warning: the number of keys MUST fit into an Int.

n is equal to the number of keys.

Constructors

TotalArray (Vector a) 

Instances

Functor (TotalArray k) Source # 

Methods

fmap :: (a -> b) -> TotalArray k a -> TotalArray k b #

(<$) :: a -> TotalArray k b -> TotalArray k a #

(Enum k, Bounded k) => Applicative (TotalArray k) Source #

Zippy applicative. Complexity: pure O(n), <*> O(n).

Methods

pure :: a -> TotalArray k a #

(<*>) :: TotalArray k (a -> b) -> TotalArray k a -> TotalArray k b #

(*>) :: TotalArray k a -> TotalArray k b -> TotalArray k b #

(<*) :: TotalArray k a -> TotalArray k b -> TotalArray k a #

Foldable (TotalArray k) Source # 

Methods

fold :: Monoid m => TotalArray k m -> m #

foldMap :: Monoid m => (a -> m) -> TotalArray k a -> m #

foldr :: (a -> b -> b) -> b -> TotalArray k a -> b #

foldr' :: (a -> b -> b) -> b -> TotalArray k a -> b #

foldl :: (b -> a -> b) -> b -> TotalArray k a -> b #

foldl' :: (b -> a -> b) -> b -> TotalArray k a -> b #

foldr1 :: (a -> a -> a) -> TotalArray k a -> a #

foldl1 :: (a -> a -> a) -> TotalArray k a -> a #

toList :: TotalArray k a -> [a] #

null :: TotalArray k a -> Bool #

length :: TotalArray k a -> Int #

elem :: Eq a => a -> TotalArray k a -> Bool #

maximum :: Ord a => TotalArray k a -> a #

minimum :: Ord a => TotalArray k a -> a #

sum :: Num a => TotalArray k a -> a #

product :: Num a => TotalArray k a -> a #

Traversable (TotalArray k) Source # 

Methods

traverse :: Applicative f => (a -> f b) -> TotalArray k a -> f (TotalArray k b) #

sequenceA :: Applicative f => TotalArray k (f a) -> f (TotalArray k a) #

mapM :: Monad m => (a -> m b) -> TotalArray k a -> m (TotalArray k b) #

sequence :: Monad m => TotalArray k (m a) -> m (TotalArray k a) #

(Enum k, Bounded k) => Distributive (TotalArray k) Source #

Complexity: distribute O(n * fmap)

Methods

distribute :: Functor f => f (TotalArray k a) -> TotalArray k (f a) #

collect :: Functor f => (a -> TotalArray k b) -> f a -> TotalArray k (f b) #

distributeM :: Monad m => m (TotalArray k a) -> TotalArray k (m a) #

collectM :: Monad m => (a -> TotalArray k b) -> m a -> TotalArray k (m b) #

(Enum k, Bounded k) => Representable (TotalArray k) Source #

Convert from and to a total function.

Complexity: tabulate O(n), index O(1)

Associated Types

type Rep (TotalArray k :: * -> *) :: * #

Methods

tabulate :: (Rep (TotalArray k) -> a) -> TotalArray k a #

index :: TotalArray k a -> Rep (TotalArray k) -> a #

(Enum k, Bounded k) => Serial1 (TotalArray k) Source #

Complexity: serializeWith O(n), deserializeWith O(n)

Methods

serializeWith :: MonadPut m => (a -> m ()) -> TotalArray k a -> m () #

deserializeWith :: MonadGet m => m a -> m (TotalArray k a) #

(Enum k, Bounded k) => Keyed (TotalArray k) Source #

Complexity: mapWithKey O(n)

Methods

mapWithKey :: (Key (TotalArray k) -> a -> b) -> TotalArray k a -> TotalArray k b #

Zip (TotalArray k) Source #

Complexity: all O(n)

Methods

zipWith :: (a -> b -> c) -> TotalArray k a -> TotalArray k b -> TotalArray k c #

zip :: TotalArray k a -> TotalArray k b -> TotalArray k (a, b) #

zap :: TotalArray k (a -> b) -> TotalArray k a -> TotalArray k b #

(Enum k, Bounded k) => ZipWithKey (TotalArray k) Source #

Complexity: all O(n)

Methods

zipWithKey :: (Key (TotalArray k) -> a -> b -> c) -> TotalArray k a -> TotalArray k b -> TotalArray k c #

zapWithKey :: TotalArray k (Key (TotalArray k) -> a -> b) -> TotalArray k a -> TotalArray k b #

(Enum k, Bounded k) => Indexable (TotalArray k) Source #

Complexity: index O(1)

Methods

index :: TotalArray k a -> Key (TotalArray k) -> a #

(Enum k, Bounded k) => Lookup (TotalArray k) Source #

Complexity: lookup O(1)

Methods

lookup :: Key (TotalArray k) -> TotalArray k a -> Maybe a #

(Enum k, Bounded k) => Adjustable (TotalArray k) Source #

Complexity: adjust O(n)

Methods

adjust :: (a -> a) -> Key (TotalArray k) -> TotalArray k a -> TotalArray k a #

replace :: Key (TotalArray k) -> a -> TotalArray k a -> TotalArray k a #

(Enum k, Bounded k) => FoldableWithKey (TotalArray k) Source #

Complexity: foldMapWithKey O(n)

Methods

toKeyedList :: TotalArray k a -> [(Key (TotalArray k), a)] #

foldMapWithKey :: Monoid m => (Key (TotalArray k) -> a -> m) -> TotalArray k a -> m #

foldrWithKey :: (Key (TotalArray k) -> a -> b -> b) -> b -> TotalArray k a -> b #

foldlWithKey :: (b -> Key (TotalArray k) -> a -> b) -> b -> TotalArray k a -> b #

(Enum k, Bounded k) => TraversableWithKey (TotalArray k) Source #

Complexity: traverseWithKey O(n)

Methods

traverseWithKey :: Applicative f => (Key (TotalArray k) -> a -> f b) -> TotalArray k a -> f (TotalArray k b) #

mapWithKeyM :: Monad m => (Key (TotalArray k) -> a -> m b) -> TotalArray k a -> m (TotalArray k b) #

(Enum k, Bounded k) => Metric (TotalArray k) Source #

Complexity: all O(n)

Methods

dot :: Num a => TotalArray k a -> TotalArray k a -> a #

quadrance :: Num a => TotalArray k a -> a #

qd :: Num a => TotalArray k a -> TotalArray k a -> a #

distance :: Floating a => TotalArray k a -> TotalArray k a -> a #

norm :: Floating a => TotalArray k a -> a #

signorm :: Floating a => TotalArray k a -> TotalArray k a #

(Enum k, Bounded k) => Additive (TotalArray k) Source #

Complexity: all O(n)

Methods

zero :: Num a => TotalArray k a #

(^+^) :: Num a => TotalArray k a -> TotalArray k a -> TotalArray k a #

(^-^) :: Num a => TotalArray k a -> TotalArray k a -> TotalArray k a #

lerp :: Num a => a -> TotalArray k a -> TotalArray k a -> TotalArray k a #

liftU2 :: (a -> a -> a) -> TotalArray k a -> TotalArray k a -> TotalArray k a #

liftI2 :: (a -> b -> c) -> TotalArray k a -> TotalArray k b -> TotalArray k c #

Eq a => Eq (TotalArray k a) Source # 

Methods

(==) :: TotalArray k a -> TotalArray k a -> Bool #

(/=) :: TotalArray k a -> TotalArray k a -> Bool #

Ord a => Ord (TotalArray k a) Source # 

Methods

compare :: TotalArray k a -> TotalArray k a -> Ordering #

(<) :: TotalArray k a -> TotalArray k a -> Bool #

(<=) :: TotalArray k a -> TotalArray k a -> Bool #

(>) :: TotalArray k a -> TotalArray k a -> Bool #

(>=) :: TotalArray k a -> TotalArray k a -> Bool #

max :: TotalArray k a -> TotalArray k a -> TotalArray k a #

min :: TotalArray k a -> TotalArray k a -> TotalArray k a #

Read a => Read (TotalArray k a) Source # 
Show a => Show (TotalArray k a) Source # 

Methods

showsPrec :: Int -> TotalArray k a -> ShowS #

show :: TotalArray k a -> String #

showList :: [TotalArray k a] -> ShowS #

(Enum k, Bounded k, Serial a) => Serial (TotalArray k a) Source #

Complexity: serialize O(n), deserialize O(n)

Methods

serialize :: MonadPut m => TotalArray k a -> m () #

deserialize :: MonadGet m => m (TotalArray k a) #

type Rep (TotalArray k) Source # 
type Rep (TotalArray k) = k
type Key (TotalArray k) Source # 
type Key (TotalArray k) = k