-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | A specialization of `HashMap Int v` -- -- A specialization of `HashMap Int v` @package unordered-intmap @version 0.1.1 module Data.Unordered.IntMap -- | A map from (possibly newtyped) Int keys to values. A map cannot -- contain duplicate keys; each key can map to at most one value. data UnorderedIntMap v Empty :: UnorderedIntMap v BitmapIndexed :: {-# UNPACK #-} !Bitmap -> {-# UNPACK #-} !(SmallArray (UnorderedIntMap v)) -> UnorderedIntMap v Leaf :: {-# UNPACK #-} !(Leaf v) -> UnorderedIntMap v Full :: {-# UNPACK #-} !(SmallArray (UnorderedIntMap v)) -> UnorderedIntMap v -- | A set of values. A set cannot contain duplicate values. data Leaf v L :: {-# UNPACK #-} !Int -> v -> Leaf v -- | O(1) Construct an empty map. empty :: UnorderedIntMap v -- | O(1) Construct a map with a single element. singleton :: Coercible key Int => key -> v -> UnorderedIntMap v -- | O(1) Return True if this map is empty, False -- otherwise. null :: UnorderedIntMap v -> Bool -- | O(n) Return the number of key-value mappings in this map. size :: UnorderedIntMap v -> Int -- | O(log n) Return True if the specified key is present in -- the map, False otherwise. member :: Coercible key Int => key -> UnorderedIntMap a -> Bool -- | O(log n) Return the value to which the specified key is mapped, -- or Nothing if this map contains no mapping for the key. lookup :: Coercible key Int => key -> UnorderedIntMap v -> Maybe v -- | O(log n) Return the value to which the specified key is mapped, -- or the default value if this map contains no mapping for the key. lookupDefault :: Coercible key Int => v -> key -> UnorderedIntMap v -> v -- | O(log n) Return the value to which the specified key is mapped. -- Calls error if this map contains no mapping for the key. (!) :: Coercible key Int => UnorderedIntMap v -> key -> v infixl 9 ! -- | O(log n) Associate the specified value with the specified key -- in this map. If this map previously contained a mapping for the key, -- the old value is replaced. insert :: Coercible key Int => key -> v -> UnorderedIntMap v -> UnorderedIntMap v -- | O(log n) Associate the value with the key in this map. If this -- map previously contained a mapping for the key, the old value is -- replaced by the result of applying the given function to the new and -- old value. Example: -- --
-- insertWith f k v map -- where f new old = new + old --insertWith :: Coercible key Int => (v -> v -> v) -> key -> v -> UnorderedIntMap v -> UnorderedIntMap v -- | In-place update version of insert unsafeInsert :: Coercible key Int => key -> v -> UnorderedIntMap v -> UnorderedIntMap v -- | O(log n) Remove the mapping for the specified key from this map -- if present. delete :: Coercible key Int => key -> UnorderedIntMap v -> UnorderedIntMap v -- | O(log n) Adjust the value tied to a given key in this map only -- if it is present. Otherwise, leave the map alone. adjust :: Coercible key Int => (v -> v) -> key -> UnorderedIntMap v -> UnorderedIntMap v -- | O(log n) The expression (update f k map) -- updates the value x at k, (if it is in the map). If -- (f k x) is Nothing, the element is deleted. If it is -- (Just y), the key k is bound to the new value y. update :: Coercible key Int => (a -> Maybe a) -> key -> UnorderedIntMap a -> UnorderedIntMap a -- | O(log n) The expression (alter f k map) alters -- the value x at k, or absence thereof. alter -- can be used to insert, delete, or update a value in a map. In short : -- lookup k (alter f k m) = f (lookup k m). alter :: Coercible key Int => (Maybe v -> Maybe v) -> key -> UnorderedIntMap v -> UnorderedIntMap v -- | O(n+m) 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 :: UnorderedIntMap v -> UnorderedIntMap v -> UnorderedIntMap v -- | O(n+m) The union of two maps. If a key occurs in both maps, the -- provided function (first argument) will be used to compute the result. unionWith :: forall v. (v -> v -> v) -> UnorderedIntMap v -> UnorderedIntMap v -> UnorderedIntMap v -- | O(n+m) 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 :: Coercible key Int => (key -> v -> v -> v) -> UnorderedIntMap v -> UnorderedIntMap v -> UnorderedIntMap v -- | Construct a set containing all elements from a list of sets. unions :: [UnorderedIntMap v] -> UnorderedIntMap v -- | O(n) Transform this map by applying a function to every value. map :: forall v1 v2. (v1 -> v2) -> UnorderedIntMap v1 -> UnorderedIntMap v2 -- | O(n) Transform this map by applying a function to every value. mapWithKey :: Coercible key Int => (key -> v1 -> v2) -> UnorderedIntMap v1 -> UnorderedIntMap v2 -- | O(n) Transform this map by accumulating an Applicative result -- from every value. traverseWithKey :: (Coercible key Int, Applicative f) => (key -> v1 -> f v2) -> UnorderedIntMap v1 -> f (UnorderedIntMap v2) -- | O(n*log m) Difference of two maps. Return elements of the first -- map not existing in the second. difference :: UnorderedIntMap v -> UnorderedIntMap w -> UnorderedIntMap v -- | O(n*log m) 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 :: (v -> w -> Maybe v) -> UnorderedIntMap v -> UnorderedIntMap w -> UnorderedIntMap v -- | O(n*log m) Intersection of two maps. Return elements of the -- first map for keys existing in the second. intersection :: UnorderedIntMap v -> UnorderedIntMap w -> UnorderedIntMap v -- | O(n+m) 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 :: (v1 -> v2 -> v3) -> UnorderedIntMap v1 -> UnorderedIntMap v2 -> UnorderedIntMap v3 -- | O(n+m) 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 :: Coercible key Int => (key -> v1 -> v2 -> v3) -> UnorderedIntMap v1 -> UnorderedIntMap v2 -> UnorderedIntMap v3 -- | O(n) Reduce this map by applying a binary operator to all -- elements, using the given starting value (typically the left-identity -- of the operator). Each application of the operator is evaluated before -- before using the result in the next application. This function is -- strict in the starting value. foldl' :: (a -> v -> a) -> a -> UnorderedIntMap v -> a -- | O(n) Reduce this map by applying a binary operator to all -- elements, using the given starting value (typically the left-identity -- of the operator). Each application of the operator is evaluated before -- before using the result in the next application. This function is -- strict in the starting value. foldlWithKey' :: (a -> Int -> v -> a) -> a -> UnorderedIntMap v -> a -- | O(n) Reduce this map by applying a binary operator to all -- elements, using the given starting value (typically the right-identity -- of the operator). foldr :: (v -> a -> a) -> a -> UnorderedIntMap v -> a -- | O(n) Reduce this map by applying a binary operator to all -- elements, using the given starting value (typically the right-identity -- of the operator). foldrWithKey :: (Int -> v -> a -> a) -> a -> UnorderedIntMap v -> a -- | O(n) Transform this map by applying a function to every value -- and retaining only some of them. mapMaybe :: (v1 -> Maybe v2) -> UnorderedIntMap v1 -> UnorderedIntMap v2 -- | O(n) Transform this map by applying a function to every value -- and retaining only some of them. mapMaybeWithKey :: (Int -> v1 -> Maybe v2) -> UnorderedIntMap v1 -> UnorderedIntMap v2 -- | O(n) Filter this map by retaining only elements which values -- satisfy a predicate. filter :: (v -> Bool) -> UnorderedIntMap v -> UnorderedIntMap v -- | O(n) Filter this map by retaining only elements satisfying a -- predicate. filterWithKey :: forall v. (Int -> v -> Bool) -> UnorderedIntMap v -> UnorderedIntMap v -- | O(n) Return a list of this map's keys. The list is produced -- lazily. keys :: UnorderedIntMap v -> [Int] -- | O(n) Return a list of this map's values. The list is produced -- lazily. elems :: forall v. UnorderedIntMap v -> [v] -- | O(n) Return a list of this map's elements. The list is produced -- lazily. The order of its elements is unspecified. toList :: UnorderedIntMap v -> [(Int, v)] -- | O(n) Construct a map with the supplied mappings. If the list -- contains duplicate mappings, the later mappings take precedence. fromList :: [(Int, v)] -> UnorderedIntMap v -- | O(n*log n) Construct a map from a list of elements. Uses the -- provided function to merge duplicate entries. fromListWith :: Coercible key Int => (v -> v -> v) -> [(key, v)] -> UnorderedIntMap v type Bitmap = Word -- | Create a BitmapIndexed or Full node. bitmapIndexedOrFull :: Bitmap -> SmallArray (UnorderedIntMap v) -> UnorderedIntMap v mask :: Int -> Shift -> Bitmap -- | Mask out the bitsPerSubkey bits used for indexing at this level -- of the tree. index :: Int -> Shift -> Int bitsPerSubkey :: Int -- | A bitmask with the bitsPerSubkey least significant bits set. fullNodeMask :: Bitmap sparseIndex :: Bitmap -> Bitmap -> Int -- | Create a map from two key-value pairs which hashes don't collide. two :: Shift -> Int -> v -> Int -> v -> ST s (UnorderedIntMap v) -- | Strict in the result of f. unionArrayBy :: (a -> a -> a) -> Bitmap -> Bitmap -> SmallArray a -> SmallArray a -> SmallArray a -- | O(n) Update the element at the given position in this array. update16 :: SmallArray e -> Int -> e -> SmallArray e -- | O(n) Update the element at the given position in this array. update16M :: SmallArray e -> Int -> e -> ST s (SmallArray e) -- | O(n) Update the element at the given position in this array, by -- applying a function to it. update16With' :: SmallArray e -> Int -> (e -> e) -> SmallArray e updateOrConcatWith :: forall v. (v -> v -> v) -> SmallArray (Leaf v) -> SmallArray (Leaf v) -> SmallArray (Leaf v) updateOrConcatWithKey :: (Int -> v -> v -> v) -> SmallArray (Leaf v) -> SmallArray (Leaf v) -> SmallArray (Leaf v) -- | Common implementation for filterWithKey and -- mapMaybeWithKey, allowing the former to former to reuse terms. filterMapAux :: forall v1 v2. (UnorderedIntMap v1 -> Maybe (UnorderedIntMap v2)) -> UnorderedIntMap v1 -> UnorderedIntMap v2 equalKeys :: (Int -> Int -> Bool) -> UnorderedIntMap v -> UnorderedIntMap v' -> Bool instance GHC.Classes.Eq v => GHC.Classes.Eq (Data.Unordered.IntMap.Leaf v) instance Control.DeepSeq.NFData v => Control.DeepSeq.NFData (Data.Unordered.IntMap.UnorderedIntMap v) instance GHC.Base.Functor Data.Unordered.IntMap.UnorderedIntMap instance Data.Foldable.Foldable Data.Unordered.IntMap.UnorderedIntMap instance GHC.Base.Semigroup (Data.Unordered.IntMap.UnorderedIntMap v) instance GHC.Base.Monoid (Data.Unordered.IntMap.UnorderedIntMap v) instance Data.Functor.Classes.Show1 Data.Unordered.IntMap.UnorderedIntMap instance Data.Functor.Classes.Read1 Data.Unordered.IntMap.UnorderedIntMap instance GHC.Read.Read e => GHC.Read.Read (Data.Unordered.IntMap.UnorderedIntMap e) instance GHC.Show.Show v => GHC.Show.Show (Data.Unordered.IntMap.UnorderedIntMap v) instance Data.Traversable.Traversable Data.Unordered.IntMap.UnorderedIntMap instance Data.Functor.Classes.Eq1 Data.Unordered.IntMap.UnorderedIntMap instance GHC.Classes.Eq v => GHC.Classes.Eq (Data.Unordered.IntMap.UnorderedIntMap v) instance Data.Functor.Classes.Ord1 Data.Unordered.IntMap.UnorderedIntMap instance GHC.Classes.Ord v => GHC.Classes.Ord (Data.Unordered.IntMap.UnorderedIntMap v) instance GHC.Exts.IsList (Data.Unordered.IntMap.UnorderedIntMap v) instance Control.DeepSeq.NFData v => Control.DeepSeq.NFData (Data.Unordered.IntMap.Leaf v)