-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/

-- | Efficient vector-based mutable hashtables implementation.
--   
--   This package provides efficient vector-based hashtable implementation
--   similar to .NET Generic Dictionary implementation (at the time of
--   2015).
--   
--   See Data.Vector.Hashtables for documentation.
@package vector-hashtables
@version 0.1.2.1

module Data.Primitive.PrimArray.Utils
replicate :: (PrimMonad m, Prim a) => Int -> a -> m (MutablePrimArray (PrimState m) a)
clone :: (PrimMonad m, Prim a) => MutablePrimArray (PrimState m) a -> m (MutablePrimArray (PrimState m) a)
unsafeFreeze :: PrimMonad m => MutablePrimArray (PrimState m) a -> m (PrimArray a)
unsafeThaw :: PrimMonad m => PrimArray a -> m (MutablePrimArray (PrimState m) a)
growWith :: (PrimMonad m, Prim a) => a -> MutablePrimArray (PrimState m) a -> Int -> m (MutablePrimArray (PrimState m) a)
growNoZ :: (PrimMonad m, Prim a) => MutablePrimArray (PrimState m) a -> Int -> m (MutablePrimArray (PrimState m) a)
freeze :: (PrimMonad m, Prim a) => MutablePrimArray (PrimState m) a -> m (PrimArray a)
length :: (PrimMonad m, Prim a) => MutablePrimArray (PrimState m) a -> m Int

module Data.Vector.Hashtables.Internal.Mask

-- | Int mask. For 32-bit it is equal to 0x7FFFFFFF.
--   Otherwise, 0x7FFFFFFFFFFFFFFF.
mask :: Int

module Data.Vector.Hashtables.Internal

-- | Alias for MutablePrimArray s Int.
type IntArray s = MutablePrimArray s Int

-- | Single-element mutable array of Dictionary_ with primitive
--   state token parameterized with state, keys and values types.
--   
--   Different flavors of MVector could be used for keys and values.
--   It's preferable to use Data.Vector.Unboxed.Mutable or
--   Data.Vector.Storable.Mutable if possible. Otherwise, if you
--   must use boxed vectors, consider employing strict ones from
--   strict-containers to eliminate potential accumulation
--   of thunks.
--   
--   
Example
--   
--   
--   >>> import qualified Data.Vector.Storable.Mutable as VM
--   
--   >>> import qualified Data.Vector.Unboxed.Mutable  as UM
--   
--   >>> import Data.Vector.Hashtables
--   
--   >>> type HashTable k v = Dictionary (PrimState IO) VM.MVector k UM.MVector v
--   
newtype Dictionary s (ks :: Type -> Type -> Type) k (vs :: Type -> Type -> Type) v
DRef :: MutVar s (Dictionary_ s ks k vs v) -> Dictionary s (ks :: Type -> Type -> Type) k (vs :: Type -> Type -> Type) v
[getDRef] :: Dictionary s (ks :: Type -> Type -> Type) k (vs :: Type -> Type -> Type) v -> MutVar s (Dictionary_ s ks k vs v)

-- | Represents collection of hashtable internal primitive arrays and
--   vectors.
--   
--   
--   
- hash codes,
--   
- references to the next element,
--   
- buckets,
--   
- keys
--   
- and values.
--   
data Dictionary_ s (ks :: Type -> Type -> Type) k (vs :: Type -> Type -> Type) v
Dictionary :: !IntArray s -> !IntArray s -> !IntArray s -> !IntArray s -> !ks s k -> !vs s v -> {-# UNPACK #-} !FastRem -> Dictionary_ s (ks :: Type -> Type -> Type) k (vs :: Type -> Type -> Type) v
[hashCode] :: Dictionary_ s (ks :: Type -> Type -> Type) k (vs :: Type -> Type -> Type) v -> !IntArray s
[next] :: Dictionary_ s (ks :: Type -> Type -> Type) k (vs :: Type -> Type -> Type) v -> !IntArray s
[buckets] :: Dictionary_ s (ks :: Type -> Type -> Type) k (vs :: Type -> Type -> Type) v -> !IntArray s
[refs] :: Dictionary_ s (ks :: Type -> Type -> Type) k (vs :: Type -> Type -> Type) v -> !IntArray s
[key] :: Dictionary_ s (ks :: Type -> Type -> Type) k (vs :: Type -> Type -> Type) v -> !ks s k
[value] :: Dictionary_ s (ks :: Type -> Type -> Type) k (vs :: Type -> Type -> Type) v -> !vs s v
[remSize] :: Dictionary_ s (ks :: Type -> Type -> Type) k (vs :: Type -> Type -> Type) v -> {-# UNPACK #-} !FastRem
getCount :: Int
getFreeList :: Int
getFreeCount :: Int

-- | Represents immutable dictionary as collection of immutable arrays and
--   vectors. See unsafeFreeze and unsafeThaw for conversions
--   from/to mutable dictionary.
data FrozenDictionary (ks :: Type -> Type) k (vs :: Type -> Type) v
FrozenDictionary :: !PrimArray Int -> !PrimArray Int -> !PrimArray Int -> !Int -> !Int -> !Int -> !ks k -> !vs v -> {-# UNPACK #-} !FastRem -> FrozenDictionary (ks :: Type -> Type) k (vs :: Type -> Type) v
[fhashCode] :: FrozenDictionary (ks :: Type -> Type) k (vs :: Type -> Type) v -> !PrimArray Int
[fnext] :: FrozenDictionary (ks :: Type -> Type) k (vs :: Type -> Type) v -> !PrimArray Int
[fbuckets] :: FrozenDictionary (ks :: Type -> Type) k (vs :: Type -> Type) v -> !PrimArray Int
[count] :: FrozenDictionary (ks :: Type -> Type) k (vs :: Type -> Type) v -> !Int
[freeList] :: FrozenDictionary (ks :: Type -> Type) k (vs :: Type -> Type) v -> !Int
[freeCount] :: FrozenDictionary (ks :: Type -> Type) k (vs :: Type -> Type) v -> !Int
[fkey] :: FrozenDictionary (ks :: Type -> Type) k (vs :: Type -> Type) v -> !ks k
[fvalue] :: FrozenDictionary (ks :: Type -> Type) k (vs :: Type -> Type) v -> !vs v
[fremSize] :: FrozenDictionary (ks :: Type -> Type) k (vs :: Type -> Type) v -> {-# UNPACK #-} !FastRem

-- | O(1) in the best case, O(n) in the worst case. Find
--   dictionary entry by given key in immutable FrozenDictionary. If
--   entry not found -1 returned.
findElem :: forall (ks :: Type -> Type) k (vs :: Type -> Type) v. (Vector ks k, Vector vs v, Hashable k, Eq k) => FrozenDictionary ks k vs v -> k -> Int

-- | Infix version of unsafeRead.
(!~) :: (MVector v a, PrimMonad m) => v (PrimState m) a -> Int -> m a

-- | Infix version of unsafeIndex.
(!.~) :: Vector v a => v a -> Int -> a

-- | Infix version of unsafeWrite.
(<~~) :: (MVector v a, PrimMonad m) => v (PrimState m) a -> Int -> a -> m ()

-- | Infix version of readPrimArray.
(!) :: PrimMonad m => MutablePrimArray (PrimState m) Int -> Int -> m Int

-- | Infix version of indexPrimArray.
(!.) :: PrimArray Int -> Int -> Int

-- | Infix version of writePrimArray.
(<~) :: PrimMonad m => MutablePrimArray (PrimState m) Int -> Int -> Int -> m ()

-- | O(1) Dictionary with given capacity.
initialize :: forall (ks :: Type -> Type -> Type) k (vs :: Type -> Type -> Type) v m. (MVector ks k, MVector vs v, PrimMonad m) => Int -> m (Dictionary (PrimState m) ks k vs v)

-- | Create a copy of mutable dictionary.
clone :: forall (ks :: Type -> Type -> Type) k (vs :: Type -> Type -> Type) v m. (MVector ks k, MVector vs v, PrimMonad m) => Dictionary (PrimState m) ks k vs v -> m (Dictionary (PrimState m) ks k vs v)

-- | O(1) Unsafe convert a mutable dictionary to an immutable one
--   without copying. The mutable dictionary may not be used after this
--   operation.
unsafeFreeze :: forall (ks :: Type -> Type) k (vs :: Type -> Type) v m. (Vector ks k, Vector vs v, PrimMonad m) => Dictionary (PrimState m) (Mutable ks) k (Mutable vs) v -> m (FrozenDictionary ks k vs v)

-- | O(1) Unsafely convert immutable FrozenDictionary to a
--   mutable Dictionary without copying. The immutable dictionary
--   may not be used after this operation.
unsafeThaw :: forall (ks :: Type -> Type) k (vs :: Type -> Type) v m. (Vector ks k, Vector vs v, PrimMonad m) => FrozenDictionary ks k vs v -> m (Dictionary (PrimState m) (Mutable ks) k (Mutable vs) v)

-- | O(n) Retrieve list of keys from Dictionary.
keys :: forall ks k m (vs :: Type -> Type -> Type) v. (Vector ks k, PrimMonad m) => Dictionary (PrimState m) (Mutable ks) k vs v -> m (ks k)

-- | O(n) Retrieve list of values from Dictionary.
values :: forall vs v m (ks :: Type -> Type -> Type) k. (Vector vs v, PrimMonad m) => Dictionary (PrimState m) ks k (Mutable vs) v -> m (vs v)

-- | O(1) in the best case, O(n) in the worst case. Find
--   value by given key in Dictionary. Throws an error if value not
--   found.
at :: forall (ks :: Type -> Type -> Type) k (vs :: Type -> Type -> Type) v m. (MVector ks k, MVector vs v, PrimMonad m, Hashable k, Eq k) => Dictionary (PrimState m) ks k vs v -> k -> m v

-- | O(1) in the best case, O(n) in the worst case. Find
--   value by given key in Dictionary. Like at' but return
--   Nothing if value not found.
at' :: forall (ks :: Type -> Type -> Type) k (vs :: Type -> Type -> Type) v m. (MVector ks k, MVector vs v, PrimMonad m, Hashable k, Eq k) => Dictionary (PrimState m) ks k vs v -> k -> m (Maybe v)
atWithOrElse :: forall (ks :: Type -> Type -> Type) k (vs :: Type -> Type -> Type) v m a. (MVector ks k, MVector vs v, PrimMonad m, Hashable k, Eq k) => Dictionary (PrimState m) ks k vs v -> k -> (Dictionary (PrimState m) ks k vs v -> Int -> m a) -> (Dictionary (PrimState m) ks k vs v -> m a) -> m a

-- | O(1) in the best case, O(n) in the worst case. Find
--   dictionary entry by given key. If entry not found -1
--   returned.
findEntry :: forall (ks :: Type -> Type -> Type) k (vs :: Type -> Type -> Type) v m. (MVector ks k, MVector vs v, PrimMonad m, Hashable k, Eq k) => Dictionary (PrimState m) ks k vs v -> k -> m Int

-- | O(1) in the best case, O(n) in the worst case. Same as
--   findEntry, but for Dictionary_.
findEntry_ :: forall (ks :: Type -> Type -> Type) k (vs :: Type -> Type -> Type) v m. (MVector ks k, MVector vs v, PrimMonad m, Hashable k, Eq k) => Dictionary_ (PrimState m) ks k vs v -> k -> m Int

-- | O(1) in the best case, O(n) in the worst case. Insert
--   key and value in dictionary by key's hash. If entry with given key
--   found value will be replaced.
insert :: forall (ks :: Type -> Type -> Type) k (vs :: Type -> Type -> Type) v m. (MVector ks k, MVector vs v, PrimMonad m, Hashable k, Eq k) => Dictionary (PrimState m) ks k vs v -> k -> v -> m ()
insertWithIndex :: forall (ks :: Type -> Type -> Type) k (vs :: Type -> Type -> Type) v m. (MVector ks k, MVector vs v, PrimMonad m, Hashable k, Eq k) => Int -> Int -> k -> v -> MutVar (PrimState m) (Dictionary_ (PrimState m) ks k vs v) -> Dictionary_ (PrimState m) ks k vs v -> Int -> m ()
addOrResize :: forall (ks :: Type -> Type -> Type) k (vs :: Type -> Type -> Type) v m. (MVector ks k, MVector vs v, PrimMonad m, Hashable k, Eq k) => Int -> Int -> k -> v -> MutVar (PrimState m) (Dictionary_ (PrimState m) ks k vs v) -> Dictionary_ (PrimState m) ks k vs v -> m ()
add :: forall (ks :: Type -> Type -> Type) k (vs :: Type -> Type -> Type) v m. (MVector ks k, MVector vs v, PrimMonad m, Hashable k, Eq k) => Int -> Int -> Int -> k -> v -> Dictionary_ (PrimState m) ks k vs v -> m ()
resize :: forall (ks :: Type -> Type -> Type) k (vs :: Type -> Type -> Type) v m. (MVector ks k, MVector vs v, PrimMonad m, Hashable k, Eq k) => Dictionary_ (PrimState m) ks k vs v -> Int -> Int -> k -> v -> m (Dictionary_ (PrimState m) ks k vs v)
class DeleteEntry (xs :: Type -> Type -> Type)
deleteEntry :: (DeleteEntry xs, MVector xs x, PrimMonad m) => xs (PrimState m) x -> Int -> m ()

-- | O(1) in the best case, O(n) in the worst case. Delete
--   entry from Dictionary by given key.
delete :: forall k (ks :: Type -> Type -> Type) (vs :: Type -> Type -> Type) v m. (Eq k, MVector ks k, MVector vs v, Hashable k, PrimMonad m, DeleteEntry ks, DeleteEntry vs) => Dictionary (PrimState m) ks k vs v -> k -> m ()
deleteWithIndex :: forall k (ks :: Type -> Type -> Type) (vs :: Type -> Type -> Type) v m. (Eq k, MVector ks k, MVector vs v, Hashable k, PrimMonad m, DeleteEntry ks, DeleteEntry vs) => Int -> Int -> Dictionary_ (PrimState m) ks k vs v -> k -> Int -> Int -> m ()

-- | O(1) in the best case, O(n) in the worst case. Find
--   value by given key in Dictionary. Like lookup' but
--   return Nothing if value not found.
lookup :: forall (ks :: Type -> Type -> Type) k (vs :: Type -> Type -> Type) v m. (MVector ks k, MVector vs v, PrimMonad m, Hashable k, Eq k) => Dictionary (PrimState m) ks k vs v -> k -> m (Maybe v)

-- | O(1) in the best case, O(n) in the worst case. Find
--   value by given key in Dictionary. Throws an error if value not
--   found.
lookup' :: forall (ks :: Type -> Type -> Type) k (vs :: Type -> Type -> Type) v m. (MVector ks k, MVector vs v, PrimMonad m, Hashable k, Eq k) => Dictionary (PrimState m) ks k vs v -> k -> m v

-- | O(1) in the best case, O(n) in the worst case. Lookup
--   the index of a key, which is its zero-based index in the sequence
--   sorted by keys. The index is a number from 0 up to, but not including,
--   the size of the dictionary.
lookupIndex :: forall (ks :: Type -> Type -> Type) k (vs :: Type -> Type -> Type) v m. (MVector ks k, MVector vs v, PrimMonad m, Hashable k, Eq k) => Dictionary (PrimState m) ks k vs v -> k -> m (Maybe Int)

-- | O(1) Return True if dictionary is empty, False
--   otherwise.
null :: forall (ks :: Type -> Type -> Type) k m (vs :: Type -> Type -> Type) v. (MVector ks k, PrimMonad m) => Dictionary (PrimState m) ks k vs v -> m Bool

-- | O(1) Return the number of non-empty entries of dictionary.
length :: forall (ks :: Type -> Type -> Type) k m (vs :: Type -> Type -> Type) v. (MVector ks k, PrimMonad m) => Dictionary (PrimState m) ks k vs v -> m Int

-- | O(1) Return the number of non-empty entries of dictionary.
--   Synonym of length.
size :: forall (ks :: Type -> Type -> Type) k m (vs :: Type -> Type -> Type) v. (MVector ks k, PrimMonad m) => Dictionary (PrimState m) ks k vs v -> m Int

-- | O(1) in the best case, O(n) in the worst case. Return
--   True if the specified key is present in the dictionary,
--   False otherwise.
member :: forall (ks :: Type -> Type -> Type) k (vs :: Type -> Type -> Type) v m. (MVector ks k, MVector vs v, PrimMonad m, Hashable k, Eq k) => Dictionary (PrimState m) ks k vs v -> k -> m Bool

-- | O(1) in the best case, O(n) in the worst case. The
--   expression findWithDefault ht def k returns the value
--   at key k or returns default value def when the key
--   is not in the dictionary.
findWithDefault :: forall (ks :: Type -> Type -> Type) k (vs :: Type -> Type -> Type) v m. (MVector ks k, MVector vs v, PrimMonad m, Hashable k, Eq k) => Dictionary (PrimState m) ks k vs v -> v -> k -> m v

-- | O(1) in the best case, O(n) in the worst case. The
--   expression (upsert ht f k) updates or inserts the
--   value x at k.
--   
--   It's a responsibility of MVector vs to force
--   evaluation of the updated value. Unboxed / storable vectors do it
--   automatically. If you use boxed vectors, consider employing strict
--   ones from strict-containers to eliminate potential
--   accumulation of thunks.
--   
--   
--   let f _ = "c"
--   ht <- fromList [(5,"a"), (3,"b")]
--   upsert ht f 7
--   toList ht
--   [(3, "b"), (5, "a"), (7, "c")]
--   
--   
--   
--   ht <- fromList [(5,"a"), (3,"b")]
--   upsert ht f 5
--   toList ht
--   [(3, "b"), (5, "c")]
--   
upsert :: forall (ks :: Type -> Type -> Type) k (vs :: Type -> Type -> Type) v m. (MVector ks k, MVector vs v, PrimMonad m, Hashable k, Eq k) => Dictionary (PrimState m) ks k vs v -> (Maybe v -> v) -> k -> m ()

-- | O(1) in the best case, O(n) in the worst case. The
--   expression (alter ht f k) alters the value x
--   at k, or absence thereof. alter can be used to insert,
--   delete, or update a value in a Dictionary.
--   
--   It's a responsibility of MVector vs to force
--   evaluation of the updated value. Unboxed / storable vectors do it
--   automatically. If you use boxed vectors, consider employing strict
--   ones from strict-containers to eliminate potential
--   accumulation of thunks.
--   
--   
--   let f _ = Nothing
--   ht <- fromList [(5,"a"), (3,"b")]
--   alter ht f 7
--   toList ht
--   [(3, "b"), (5, "a")]
--   
--   
--   
--   ht <- fromList [(5,"a"), (3,"b")]
--   alter ht f 5
--   toList ht
--   [(3 "b")]
--   
--   
--   
--   let f _ = Just "c"
--   ht <- fromList [(5,"a"), (3,"b")]
--   alter ht f 7
--   toList ht
--   [(3, "b"), (5, "a"), (7, "c")]
--   
--   
--   
--   ht <- fromList [(5,"a"), (3,"b")]
--   alter ht f 5
--   toList ht
--   [(3, "b"), (5, "c")]
--   
alter :: forall (ks :: Type -> Type -> Type) k (vs :: Type -> Type -> Type) v m. (MVector ks k, MVector vs v, DeleteEntry ks, DeleteEntry vs, PrimMonad m, Hashable k, Eq k) => Dictionary (PrimState m) ks k vs v -> (Maybe v -> Maybe v) -> k -> m ()

-- | O(1) in the best case, O(n) in the worst case. The
--   expression (alterM ht f k) alters the value x
--   at k, or absence thereof. alterM can be used to
--   insert, delete, or update a value in a Dictionary in the same
--   PrimMonad m.
alterM :: forall (ks :: Type -> Type -> Type) k (vs :: Type -> Type -> Type) v m. (MVector ks k, MVector vs v, DeleteEntry ks, DeleteEntry vs, PrimMonad m, Hashable k, Eq k) => Dictionary (PrimState m) ks k vs v -> (Maybe v -> m (Maybe v)) -> k -> m ()

-- | O(min n m) in the best case, O(min n m * max n m) in the
--   worst case. The union of two maps. If a key occurs in both maps, the
--   mapping from the first will be the mapping in the result.
union :: forall (ks :: Type -> Type -> Type) k (vs :: Type -> Type -> Type) v m. (MVector ks k, MVector vs v, PrimMonad m, Hashable k, Eq k) => Dictionary (PrimState m) ks k vs v -> Dictionary (PrimState m) ks k vs v -> m (Dictionary (PrimState m) ks k vs v)

-- | O(min n m) in the best case, O(min n m * max n m) in the
--   worst case. The union of two maps. The provided function (first
--   argument) will be used to compute the result.
unionWith :: forall (ks :: Type -> Type -> Type) k (vs :: Type -> Type -> Type) v m. (MVector ks k, MVector ks k, MVector vs v, PrimMonad m, Hashable k, Eq k) => (v -> v -> v) -> Dictionary (PrimState m) ks k vs v -> Dictionary (PrimState m) ks k vs v -> m (Dictionary (PrimState m) ks k vs v)

-- | O(min n m) in the best case, O(min n m * max n m) in the
--   worst case. The union of two maps. If a key occurs in both maps, the
--   provided function (first argument) will be used to compute the result.
unionWithKey :: forall (ks :: Type -> Type -> Type) k (vs :: Type -> Type -> Type) v m. (MVector ks k, MVector vs v, PrimMonad m, Hashable k, Eq k) => (k -> v -> v -> v) -> Dictionary (PrimState m) ks k vs v -> Dictionary (PrimState m) ks k vs v -> m (Dictionary (PrimState m) ks k vs v)

-- | O(n) in the best case, O(n * m) in the worst case.
--   Difference of two tables. Return elements of the first table not
--   existing in the second.
difference :: forall (ks :: Type -> Type -> Type) k (vs :: Type -> Type -> Type) v w m. (MVector ks k, MVector vs v, MVector vs w, PrimMonad m, Hashable k, Eq k) => Dictionary (PrimState m) ks k vs v -> Dictionary (PrimState m) ks k vs w -> m (Dictionary (PrimState m) ks k vs v)

-- | O(n) in the best case, O(n * m) in the worst case.
--   Difference with a combining function. When two equal keys are
--   encountered, the combining function is applied to the values of these
--   keys. If it returns Nothing, the element is discarded (proper
--   set difference). If it returns (Just y), the element
--   is updated with a new value y.
differenceWith :: forall (ks :: Type -> Type -> Type) k (vs :: Type -> Type -> Type) v w m. (MVector ks k, MVector vs v, MVector vs w, PrimMonad m, Hashable k, Eq k) => (v -> w -> Maybe v) -> Dictionary (PrimState m) ks k vs v -> Dictionary (PrimState m) ks k vs w -> m (Dictionary (PrimState m) ks k vs v)

-- | O(n) in the best case, O(n * m) in the worst case.
--   Intersection of two maps. Return elements of the first map for keys
--   existing in the second.
intersection :: forall (ks :: Type -> Type -> Type) k (vs :: Type -> Type -> Type) v w m. (MVector ks k, MVector vs v, MVector vs w, PrimMonad m, Hashable k, Eq k) => Dictionary (PrimState m) ks k vs v -> Dictionary (PrimState m) ks k vs w -> m (Dictionary (PrimState m) ks k vs v)

-- | Intersection of two maps. If a key occurs in both maps the provided
--   function is used to combine the values from the two maps.
intersectionWith :: forall (ks :: Type -> Type -> Type) k (vs :: Type -> Type -> Type) v1 v2 v3 m. (MVector ks k, MVector vs v1, MVector vs v2, MVector vs v3, PrimMonad m, Hashable k, Eq k) => (v1 -> v2 -> v3) -> Dictionary (PrimState m) ks k vs v1 -> Dictionary (PrimState m) ks k vs v2 -> m (Dictionary (PrimState m) ks k vs v3)

-- | Intersection of two maps. If a key occurs in both maps the provided
--   function is used to combine the values from the two maps.
intersectionWithKey :: forall (ks :: Type -> Type -> Type) k (vs :: Type -> Type -> Type) v1 v2 v3 m. (MVector ks k, MVector vs v1, MVector vs v2, MVector vs v3, PrimMonad m, Hashable k, Eq k) => (k -> v1 -> v2 -> v3) -> Dictionary (PrimState m) ks k vs v1 -> Dictionary (PrimState m) ks k vs v2 -> m (Dictionary (PrimState m) ks k vs v3)

-- | O(n) Convert list to a Dictionary.
fromList :: forall (ks :: Type -> Type -> Type) k (vs :: Type -> Type -> Type) v m. (MVector ks k, MVector vs v, PrimMonad m, Hashable k, Eq k) => [(k, v)] -> m (Dictionary (PrimState m) ks k vs v)

-- | O(n) Convert Dictionary to a list.
toList :: forall (ks :: Type -> Type -> Type) k (vs :: Type -> Type -> Type) v m. (MVector ks k, MVector vs v, PrimMonad m, Hashable k, Eq k) => Dictionary (PrimState m) ks k vs v -> m [(k, v)]

-- | This data is auto-generated by GenPrimes.hs. The vector contains
--   tuples (p, m, s) such that p is prime and (assuming 64-bit
--   architecture) for every n >= 0 it holds that n `<a>quot</a>` p = (n
--   * m) `<a>shiftR</a>` (64 + s), enabling faster computation of
--   remainders.
primesWithFastRem :: Vector (Int, Int, Int)
getFastRem :: Int -> FastRem

-- | For 64-bit architectures frmPrime is a prime number such that
--   for each n >= 0 it holds that n `<a>quot</a>`
--   frmPrime = (n * _frmMulHi) `<a>shiftR</a>` (64 + s).
data FastRem
FastRem :: !Int -> !Int -> !Int -> FastRem
[frmPrime] :: FastRem -> !Int
[_frmMulHi] :: FastRem -> !Int
[_frmShift] :: FastRem -> !Int
fastRem :: Int -> FastRem -> Int
instance Data.Vector.Hashtables.Internal.DeleteEntry Data.Vector.Mutable.MVector
instance Data.Vector.Hashtables.Internal.DeleteEntry Data.Vector.Unboxed.Base.MVector
instance Data.Vector.Hashtables.Internal.DeleteEntry Data.Vector.Storable.Mutable.MVector
instance GHC.Classes.Eq Data.Vector.Hashtables.Internal.FastRem
instance (GHC.Classes.Eq (ks k), GHC.Classes.Eq (vs v)) => GHC.Classes.Eq (Data.Vector.Hashtables.Internal.FrozenDictionary ks k vs v)
instance GHC.Classes.Ord Data.Vector.Hashtables.Internal.FastRem
instance (GHC.Classes.Ord (ks k), GHC.Classes.Ord (vs v)) => GHC.Classes.Ord (Data.Vector.Hashtables.Internal.FrozenDictionary ks k vs v)
instance GHC.Internal.Show.Show Data.Vector.Hashtables.Internal.FastRem
instance (GHC.Internal.Show.Show (ks k), GHC.Internal.Show.Show (vs v)) => GHC.Internal.Show.Show (Data.Vector.Hashtables.Internal.FrozenDictionary ks k vs v)

module Data.Vector.Hashtables

-- | Single-element mutable array of Dictionary_ with primitive
--   state token parameterized with state, keys and values types.
--   
--   Different flavors of MVector could be used for keys and values.
--   It's preferable to use Data.Vector.Unboxed.Mutable or
--   Data.Vector.Storable.Mutable if possible. Otherwise, if you
--   must use boxed vectors, consider employing strict ones from
--   strict-containers to eliminate potential accumulation
--   of thunks.
--   
--   
Example
--   
--   
--   >>> import qualified Data.Vector.Storable.Mutable as VM
--   
--   >>> import qualified Data.Vector.Unboxed.Mutable  as UM
--   
--   >>> import Data.Vector.Hashtables
--   
--   >>> type HashTable k v = Dictionary (PrimState IO) VM.MVector k UM.MVector v
--   
newtype Dictionary s (ks :: Type -> Type -> Type) k (vs :: Type -> Type -> Type) v
DRef :: MutVar s (Dictionary_ s ks k vs v) -> Dictionary s (ks :: Type -> Type -> Type) k (vs :: Type -> Type -> Type) v
[getDRef] :: Dictionary s (ks :: Type -> Type -> Type) k (vs :: Type -> Type -> Type) v -> MutVar s (Dictionary_ s ks k vs v)

-- | Represents immutable dictionary as collection of immutable arrays and
--   vectors. See unsafeFreeze and unsafeThaw for conversions
--   from/to mutable dictionary.
data FrozenDictionary (ks :: Type -> Type) k (vs :: Type -> Type) v
FrozenDictionary :: !PrimArray Int -> !PrimArray Int -> !PrimArray Int -> !Int -> !Int -> !Int -> !ks k -> !vs v -> {-# UNPACK #-} !FastRem -> FrozenDictionary (ks :: Type -> Type) k (vs :: Type -> Type) v
[fhashCode] :: FrozenDictionary (ks :: Type -> Type) k (vs :: Type -> Type) v -> !PrimArray Int
[fnext] :: FrozenDictionary (ks :: Type -> Type) k (vs :: Type -> Type) v -> !PrimArray Int
[fbuckets] :: FrozenDictionary (ks :: Type -> Type) k (vs :: Type -> Type) v -> !PrimArray Int
[count] :: FrozenDictionary (ks :: Type -> Type) k (vs :: Type -> Type) v -> !Int
[freeList] :: FrozenDictionary (ks :: Type -> Type) k (vs :: Type -> Type) v -> !Int
[freeCount] :: FrozenDictionary (ks :: Type -> Type) k (vs :: Type -> Type) v -> !Int
[fkey] :: FrozenDictionary (ks :: Type -> Type) k (vs :: Type -> Type) v -> !ks k
[fvalue] :: FrozenDictionary (ks :: Type -> Type) k (vs :: Type -> Type) v -> !vs v
[fremSize] :: FrozenDictionary (ks :: Type -> Type) k (vs :: Type -> Type) v -> {-# UNPACK #-} !FastRem

-- | O(1) in the best case, O(n) in the worst case. Find
--   dictionary entry by given key in immutable FrozenDictionary. If
--   entry not found -1 returned.
findElem :: forall (ks :: Type -> Type) k (vs :: Type -> Type) v. (Vector ks k, Vector vs v, Hashable k, Eq k) => FrozenDictionary ks k vs v -> k -> Int

-- | O(1) Dictionary with given capacity.
initialize :: forall (ks :: Type -> Type -> Type) k (vs :: Type -> Type -> Type) v m. (MVector ks k, MVector vs v, PrimMonad m) => Int -> m (Dictionary (PrimState m) ks k vs v)

-- | Create a copy of mutable dictionary.
clone :: forall (ks :: Type -> Type -> Type) k (vs :: Type -> Type -> Type) v m. (MVector ks k, MVector vs v, PrimMonad m) => Dictionary (PrimState m) ks k vs v -> m (Dictionary (PrimState m) ks k vs v)

-- | O(1) Return True if dictionary is empty, False
--   otherwise.
null :: forall (ks :: Type -> Type -> Type) k m (vs :: Type -> Type -> Type) v. (MVector ks k, PrimMonad m) => Dictionary (PrimState m) ks k vs v -> m Bool

-- | O(1) Return the number of non-empty entries of dictionary.
--   Synonym of length.
size :: forall (ks :: Type -> Type -> Type) k m (vs :: Type -> Type -> Type) v. (MVector ks k, PrimMonad m) => Dictionary (PrimState m) ks k vs v -> m Int

-- | O(n) Retrieve list of keys from Dictionary.
keys :: forall ks k m (vs :: Type -> Type -> Type) v. (Vector ks k, PrimMonad m) => Dictionary (PrimState m) (Mutable ks) k vs v -> m (ks k)

-- | O(n) Retrieve list of values from Dictionary.
values :: forall vs v m (ks :: Type -> Type -> Type) k. (Vector vs v, PrimMonad m) => Dictionary (PrimState m) ks k (Mutable vs) v -> m (vs v)

-- | O(1) in the best case, O(n) in the worst case. Find
--   value by given key in Dictionary. Like lookup' but
--   return Nothing if value not found.
lookup :: forall (ks :: Type -> Type -> Type) k (vs :: Type -> Type -> Type) v m. (MVector ks k, MVector vs v, PrimMonad m, Hashable k, Eq k) => Dictionary (PrimState m) ks k vs v -> k -> m (Maybe v)

-- | O(1) in the best case, O(n) in the worst case. Find
--   value by given key in Dictionary. Throws an error if value not
--   found.
lookup' :: forall (ks :: Type -> Type -> Type) k (vs :: Type -> Type -> Type) v m. (MVector ks k, MVector vs v, PrimMonad m, Hashable k, Eq k) => Dictionary (PrimState m) ks k vs v -> k -> m v

-- | O(1) in the best case, O(n) in the worst case. Insert
--   key and value in dictionary by key's hash. If entry with given key
--   found value will be replaced.
insert :: forall (ks :: Type -> Type -> Type) k (vs :: Type -> Type -> Type) v m. (MVector ks k, MVector vs v, PrimMonad m, Hashable k, Eq k) => Dictionary (PrimState m) ks k vs v -> k -> v -> m ()

-- | O(1) in the best case, O(n) in the worst case. Delete
--   entry from Dictionary by given key.
delete :: forall k (ks :: Type -> Type -> Type) (vs :: Type -> Type -> Type) v m. (Eq k, MVector ks k, MVector vs v, Hashable k, PrimMonad m, DeleteEntry ks, DeleteEntry vs) => Dictionary (PrimState m) ks k vs v -> k -> m ()

-- | O(1) in the best case, O(n) in the worst case. The
--   expression (upsert ht f k) updates or inserts the
--   value x at k.
--   
--   It's a responsibility of MVector vs to force
--   evaluation of the updated value. Unboxed / storable vectors do it
--   automatically. If you use boxed vectors, consider employing strict
--   ones from strict-containers to eliminate potential
--   accumulation of thunks.
--   
--   
--   let f _ = "c"
--   ht <- fromList [(5,"a"), (3,"b")]
--   upsert ht f 7
--   toList ht
--   [(3, "b"), (5, "a"), (7, "c")]
--   
--   
--   
--   ht <- fromList [(5,"a"), (3,"b")]
--   upsert ht f 5
--   toList ht
--   [(3, "b"), (5, "c")]
--   
upsert :: forall (ks :: Type -> Type -> Type) k (vs :: Type -> Type -> Type) v m. (MVector ks k, MVector vs v, PrimMonad m, Hashable k, Eq k) => Dictionary (PrimState m) ks k vs v -> (Maybe v -> v) -> k -> m ()

-- | O(1) in the best case, O(n) in the worst case. The
--   expression (alter ht f k) alters the value x
--   at k, or absence thereof. alter can be used to insert,
--   delete, or update a value in a Dictionary.
--   
--   It's a responsibility of MVector vs to force
--   evaluation of the updated value. Unboxed / storable vectors do it
--   automatically. If you use boxed vectors, consider employing strict
--   ones from strict-containers to eliminate potential
--   accumulation of thunks.
--   
--   
--   let f _ = Nothing
--   ht <- fromList [(5,"a"), (3,"b")]
--   alter ht f 7
--   toList ht
--   [(3, "b"), (5, "a")]
--   
--   
--   
--   ht <- fromList [(5,"a"), (3,"b")]
--   alter ht f 5
--   toList ht
--   [(3 "b")]
--   
--   
--   
--   let f _ = Just "c"
--   ht <- fromList [(5,"a"), (3,"b")]
--   alter ht f 7
--   toList ht
--   [(3, "b"), (5, "a"), (7, "c")]
--   
--   
--   
--   ht <- fromList [(5,"a"), (3,"b")]
--   alter ht f 5
--   toList ht
--   [(3, "b"), (5, "c")]
--   
alter :: forall (ks :: Type -> Type -> Type) k (vs :: Type -> Type -> Type) v m. (MVector ks k, MVector vs v, DeleteEntry ks, DeleteEntry vs, PrimMonad m, Hashable k, Eq k) => Dictionary (PrimState m) ks k vs v -> (Maybe v -> Maybe v) -> k -> m ()

-- | O(1) in the best case, O(n) in the worst case. The
--   expression (alterM ht f k) alters the value x
--   at k, or absence thereof. alterM can be used to
--   insert, delete, or update a value in a Dictionary in the same
--   PrimMonad m.
alterM :: forall (ks :: Type -> Type -> Type) k (vs :: Type -> Type -> Type) v m. (MVector ks k, MVector vs v, DeleteEntry ks, DeleteEntry vs, PrimMonad m, Hashable k, Eq k) => Dictionary (PrimState m) ks k vs v -> (Maybe v -> m (Maybe v)) -> k -> m ()

-- | O(1) in the best case, O(n) in the worst case. Find
--   dictionary entry by given key. If entry not found -1
--   returned.
findEntry :: forall (ks :: Type -> Type -> Type) k (vs :: Type -> Type -> Type) v m. (MVector ks k, MVector vs v, PrimMonad m, Hashable k, Eq k) => Dictionary (PrimState m) ks k vs v -> k -> m Int

-- | O(min n m) in the best case, O(min n m * max n m) in the
--   worst case. The union of two maps. If a key occurs in both maps, the
--   mapping from the first will be the mapping in the result.
union :: forall (ks :: Type -> Type -> Type) k (vs :: Type -> Type -> Type) v m. (MVector ks k, MVector vs v, PrimMonad m, Hashable k, Eq k) => Dictionary (PrimState m) ks k vs v -> Dictionary (PrimState m) ks k vs v -> m (Dictionary (PrimState m) ks k vs v)

-- | O(min n m) in the best case, O(min n m * max n m) in the
--   worst case. The union of two maps. The provided function (first
--   argument) will be used to compute the result.
unionWith :: forall (ks :: Type -> Type -> Type) k (vs :: Type -> Type -> Type) v m. (MVector ks k, MVector ks k, MVector vs v, PrimMonad m, Hashable k, Eq k) => (v -> v -> v) -> Dictionary (PrimState m) ks k vs v -> Dictionary (PrimState m) ks k vs v -> m (Dictionary (PrimState m) ks k vs v)

-- | O(min n m) in the best case, O(min n m * max n m) in the
--   worst case. The union of two maps. If a key occurs in both maps, the
--   provided function (first argument) will be used to compute the result.
unionWithKey :: forall (ks :: Type -> Type -> Type) k (vs :: Type -> Type -> Type) v m. (MVector ks k, MVector vs v, PrimMonad m, Hashable k, Eq k) => (k -> v -> v -> v) -> Dictionary (PrimState m) ks k vs v -> Dictionary (PrimState m) ks k vs v -> m (Dictionary (PrimState m) ks k vs v)

-- | O(n) in the best case, O(n * m) in the worst case.
--   Difference of two tables. Return elements of the first table not
--   existing in the second.
difference :: forall (ks :: Type -> Type -> Type) k (vs :: Type -> Type -> Type) v w m. (MVector ks k, MVector vs v, MVector vs w, PrimMonad m, Hashable k, Eq k) => Dictionary (PrimState m) ks k vs v -> Dictionary (PrimState m) ks k vs w -> m (Dictionary (PrimState m) ks k vs v)

-- | O(n) in the best case, O(n * m) in the worst case.
--   Difference with a combining function. When two equal keys are
--   encountered, the combining function is applied to the values of these
--   keys. If it returns Nothing, the element is discarded (proper
--   set difference). If it returns (Just y), the element
--   is updated with a new value y.
differenceWith :: forall (ks :: Type -> Type -> Type) k (vs :: Type -> Type -> Type) v w m. (MVector ks k, MVector vs v, MVector vs w, PrimMonad m, Hashable k, Eq k) => (v -> w -> Maybe v) -> Dictionary (PrimState m) ks k vs v -> Dictionary (PrimState m) ks k vs w -> m (Dictionary (PrimState m) ks k vs v)

-- | O(n) in the best case, O(n * m) in the worst case.
--   Intersection of two maps. Return elements of the first map for keys
--   existing in the second.
intersection :: forall (ks :: Type -> Type -> Type) k (vs :: Type -> Type -> Type) v w m. (MVector ks k, MVector vs v, MVector vs w, PrimMonad m, Hashable k, Eq k) => Dictionary (PrimState m) ks k vs v -> Dictionary (PrimState m) ks k vs w -> m (Dictionary (PrimState m) ks k vs v)

-- | Intersection of two maps. If a key occurs in both maps the provided
--   function is used to combine the values from the two maps.
intersectionWith :: forall (ks :: Type -> Type -> Type) k (vs :: Type -> Type -> Type) v1 v2 v3 m. (MVector ks k, MVector vs v1, MVector vs v2, MVector vs v3, PrimMonad m, Hashable k, Eq k) => (v1 -> v2 -> v3) -> Dictionary (PrimState m) ks k vs v1 -> Dictionary (PrimState m) ks k vs v2 -> m (Dictionary (PrimState m) ks k vs v3)

-- | Intersection of two maps. If a key occurs in both maps the provided
--   function is used to combine the values from the two maps.
intersectionWithKey :: forall (ks :: Type -> Type -> Type) k (vs :: Type -> Type -> Type) v1 v2 v3 m. (MVector ks k, MVector vs v1, MVector vs v2, MVector vs v3, PrimMonad m, Hashable k, Eq k) => (k -> v1 -> v2 -> v3) -> Dictionary (PrimState m) ks k vs v1 -> Dictionary (PrimState m) ks k vs v2 -> m (Dictionary (PrimState m) ks k vs v3)

-- | O(1) Unsafe convert a mutable dictionary to an immutable one
--   without copying. The mutable dictionary may not be used after this
--   operation.
unsafeFreeze :: forall (ks :: Type -> Type) k (vs :: Type -> Type) v m. (Vector ks k, Vector vs v, PrimMonad m) => Dictionary (PrimState m) (Mutable ks) k (Mutable vs) v -> m (FrozenDictionary ks k vs v)

-- | O(1) Unsafely convert immutable FrozenDictionary to a
--   mutable Dictionary without copying. The immutable dictionary
--   may not be used after this operation.
unsafeThaw :: forall (ks :: Type -> Type) k (vs :: Type -> Type) v m. (Vector ks k, Vector vs v, PrimMonad m) => FrozenDictionary ks k vs v -> m (Dictionary (PrimState m) (Mutable ks) k (Mutable vs) v)

-- | O(n) Convert list to a Dictionary.
fromList :: forall (ks :: Type -> Type -> Type) k (vs :: Type -> Type -> Type) v m. (MVector ks k, MVector vs v, PrimMonad m, Hashable k, Eq k) => [(k, v)] -> m (Dictionary (PrimState m) ks k vs v)

-- | O(n) Convert Dictionary to a list.
toList :: forall (ks :: Type -> Type -> Type) k (vs :: Type -> Type -> Type) v m. (MVector ks k, MVector vs v, PrimMonad m, Hashable k, Eq k) => Dictionary (PrimState m) ks k vs v -> m [(k, v)]

-- | Represents collection of hashtable internal primitive arrays and
--   vectors.
--   
--   
--   
- hash codes,
--   
- references to the next element,
--   
- buckets,
--   
- keys
--   
- and values.
--   
data Dictionary_ s (ks :: Type -> Type -> Type) k (vs :: Type -> Type -> Type) v
Dictionary :: !IntArray s -> !IntArray s -> !IntArray s -> !IntArray s -> !ks s k -> !vs s v -> {-# UNPACK #-} !FastRem -> Dictionary_ s (ks :: Type -> Type -> Type) k (vs :: Type -> Type -> Type) v
[hashCode] :: Dictionary_ s (ks :: Type -> Type -> Type) k (vs :: Type -> Type -> Type) v -> !IntArray s
[next] :: Dictionary_ s (ks :: Type -> Type -> Type) k (vs :: Type -> Type -> Type) v -> !IntArray s
[buckets] :: Dictionary_ s (ks :: Type -> Type -> Type) k (vs :: Type -> Type -> Type) v -> !IntArray s
[refs] :: Dictionary_ s (ks :: Type -> Type -> Type) k (vs :: Type -> Type -> Type) v -> !IntArray s
[key] :: Dictionary_ s (ks :: Type -> Type -> Type) k (vs :: Type -> Type -> Type) v -> !ks s k
[value] :: Dictionary_ s (ks :: Type -> Type -> Type) k (vs :: Type -> Type -> Type) v -> !vs s v
[remSize] :: Dictionary_ s (ks :: Type -> Type -> Type) k (vs :: Type -> Type -> Type) v -> {-# UNPACK #-} !FastRem

-- | O(1) in the best case, O(n) in the worst case. Same as
--   findEntry, but for Dictionary_.
findEntry_ :: forall (ks :: Type -> Type -> Type) k (vs :: Type -> Type -> Type) v m. (MVector ks k, MVector vs v, PrimMonad m, Hashable k, Eq k) => Dictionary_ (PrimState m) ks k vs v -> k -> m Int
