-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/
-- | Simple Data.Map-based histogram
--
-- A histogram counts occurrences of things, i.e. Histogram k
-- represents a mapping k -> Natural.
@package histogram-simple
@version 1.1
-- | Simple Map-based histogram. A histogram counts occurrences of
-- things, i.e. 'Histogram k' represents a mapping k -> Int.
-- Since it is backed by a Map from Map, it requires
-- k to have an Ord instance.
module Data.Histogram
-- | A simple Map-based histogram that counts occurrences of
-- k.
data Histogram k
-- | Convert to a histogram to a map of counts of all nonzero values
toMap :: Histogram k -> Map k Int
-- | Increase a key's count by one
increment :: Ord k => k -> Histogram k -> Histogram k
-- | Decrease a key's count by one
decrement :: Ord k => k -> Histogram k -> Histogram k
lookup :: Ord k => k -> Histogram k -> Int
(!) :: Ord k => Histogram k -> k -> Int
-- | Increase a key's count by an arbitrary number. Can also be used to
-- decrease by passing a negative value. If the count falls below zero,
-- it's set to 0.
add :: Ord k => Int -> k -> Histogram k -> Histogram k
-- | Set a key's count to an exact value. Nonpositive numbers clip to 0.
set :: Ord k => Int -> k -> Histogram k -> Histogram k
-- | Set a key's count to 0.
reset :: Ord k => k -> Histogram k -> Histogram k
-- | Check whether a key has a count of 0
zero :: Ord k => k -> Histogram k -> Bool
-- | Check whether a key has a count of at least 1.
nonzero :: Ord k => k -> Histogram k -> Bool
-- | Get the total number of elements in the map, i.e. the sum of all bins.
size :: Histogram k -> Int
-- | Check whether a histogram is empty
empty :: Histogram k -> Bool
-- | Get a list of all non-zero keys.
keys :: Histogram k -> [k]
-- | Applies a function to every key. If two keys in the original map to
-- the same value, their counts are combined.
mapKeys :: Ord k2 => (k1 -> k2) -> Histogram k1 -> Histogram k2
-- | A histogram containing one key with a count of 1.
singleton :: k -> Histogram k
singletonCount :: Ord k => k -> Int -> Histogram k
-- | O(n). The expression (split k hist) is a pair
-- (h1,h2) where all keys in h1 are lower than
-- k and all keys in h2 larger than k. Any key
-- equal to k is found in neither h1 nor h2.
split :: Ord k => k -> Histogram k -> (Histogram k, Histogram k)
splitLookup :: Ord k => k -> Histogram k -> (Histogram k, Int, Histogram k)
-- | isSubsetOf h1 h2 returns True if no key has a greater
-- count in h1 than in h2.
isSubsetOf :: Ord k => Histogram k -> Histogram k -> Bool
-- | isSubsetOfBy f h1 h2 returns True if every key in
-- h1 compares to True to its corresponding key in
-- h2 by f.
isSubsetOfBy :: Ord k => (Int -> Int -> Bool) -> Histogram k -> Histogram k -> Bool
-- | disjoint k1 k2 returns True when there is no
-- key that is nonzero in both k1 and k2.
disjoint :: Ord k => Histogram k -> Histogram k -> Bool
-- | Construct a histogram by counting occurrences in a list of keys.
fromList :: Ord k => [k] -> Histogram k
fromCountList :: Ord k => [(k, Int)] -> Histogram k
flatMap :: Ord k' => (k -> Int -> Histogram k') -> Histogram k -> Histogram k'
toList :: Histogram k -> [(k, Int)]
-- | Construct a histogram from a map, removing all elements smaller than 1
fromMap :: Map k Int -> Histogram k
-- | Construct a histogram directly from a map, without checking if every
-- element is above 1
unsafeFromMap :: Map k Int -> Histogram k
instance GHC.Show.Show k => GHC.Show.Show (Data.Histogram.Histogram k)
instance GHC.Classes.Eq k => GHC.Classes.Eq (Data.Histogram.Histogram k)
instance GHC.Classes.Ord k => GHC.Base.Semigroup (Data.Histogram.Histogram k)
instance GHC.Classes.Ord k => GHC.Base.Monoid (Data.Histogram.Histogram k)