toy-lib-0.1.0.0
Safe HaskellSafe-Inferred
LanguageHaskell2010

Data.MultiSet

Description

Multi set backed by IntMap.

Synopsis

Documentation

type MultiSet = (Int, IntMap Int) #

MultiSet: (nKeys, (key -> count))

emptyMS :: MultiSet #

\(O(1)\)

singletonMS :: Int -> MultiSet #

\(O(1)\)

fromListMS :: [Int] -> MultiSet #

\(O(N W)\)

incMS :: Int -> MultiSet -> MultiSet #

\(O(W)\) Increments key.

decMS :: Int -> MultiSet -> MultiSet #

\(O(W)\) Decrements key.

addMS :: Int -> Int -> MultiSet -> MultiSet #

\(O(W)\) Adds key by dn.

subMS :: Int -> Int -> MultiSet -> MultiSet #

\(O(W)\) Subtracts key by dn.

memberMS :: Int -> MultiSet -> Bool #

\(O(W)\)

notMemberMS :: Int -> MultiSet -> Bool #

\(O(W)\)

lookupMS :: Int -> MultiSet -> Maybe Int #

\(O(W)\)

getMS :: HasCallStack => Int -> MultiSet -> Int #

\(O(W)\) Partial alternative to lookupMS.

innerMS :: MultiSet -> IntMap Int #

\(O(1)\) Unwraps MultiSet into the underlying IntMap.