counter-0.1.0.2: An object frequency counter.

Safe HaskellSafe
LanguageHaskell2010

Data.Counter

Synopsis

Documentation

type Counter k v = Map k v Source #

The Counter type is an alias of Data.Map.Strict.Map.

empty :: Counter k v Source #

Initialize a counter with no keys.

singleton Source #

Arguments

:: Num v 
=> k

Key to be inserted.

-> Counter k v

New counter.

Initialize a counter with a single instance of a key.

updateWith Source #

Arguments

:: (Ord k, Num v) 
=> k

Key to be inserted.

-> v

Specified frequency count.

-> Counter k v

Old counter.

-> Counter k v

New counter.

Increment the frequency count of a key with a specified value.

update Source #

Arguments

:: (Ord k, Num v) 
=> k

Key to be inserted.

-> Counter k v

Old counter.

-> Counter k v

New counter.

Increment the frequency count of a key by 1.

count Source #

Arguments

:: (Ord k, Num v) 
=> [k]

List of keys.

-> Counter k v

New counter.

Convert a list of items into a counter.

union Source #

Arguments

:: (Ord k, Num v) 
=> Counter k v

First counter.

-> Counter k v

Second counter.

-> Counter k v

Union of both counters.

Returns the union of two counters.