Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
- data LinkedHashMap k v = LinkedHashMap (HashMap k (Entry v)) (IntMap (k, v)) !Int
- empty :: LinkedHashMap k v
- singleton :: (Eq k, Hashable k) => k -> v -> LinkedHashMap k v
- null :: LinkedHashMap k v -> Bool
- size :: LinkedHashMap k v -> Int
- member :: (Eq k, Hashable k) => k -> LinkedHashMap k a -> Bool
- lookup :: (Eq k, Hashable k) => k -> LinkedHashMap k v -> Maybe v
- lookupDefault :: (Eq k, Hashable k) => v -> k -> LinkedHashMap k v -> v
- (!) :: (Eq k, Hashable k) => LinkedHashMap k v -> k -> v
- insert :: (Eq k, Hashable k) => k -> v -> LinkedHashMap k v -> LinkedHashMap k v
- insertWith :: (Eq k, Hashable k) => (v -> v -> v) -> k -> v -> LinkedHashMap k v -> LinkedHashMap k v
- delete :: (Eq k, Hashable k) => k -> LinkedHashMap k v -> LinkedHashMap k v
- adjust :: (Eq k, Hashable k) => (v -> v) -> k -> LinkedHashMap k v -> LinkedHashMap k v
- union :: (Eq k, Hashable k) => LinkedHashMap k v -> LinkedHashMap k v -> LinkedHashMap k v
- unionWith :: (Eq k, Hashable k) => (v -> v -> v) -> LinkedHashMap k v -> LinkedHashMap k v -> LinkedHashMap k v
- unions :: (Eq k, Hashable k) => [LinkedHashMap k v] -> LinkedHashMap k v
- map :: (v1 -> v2) -> LinkedHashMap k v1 -> LinkedHashMap k v2
- mapWithKey :: (k -> v1 -> v2) -> LinkedHashMap k v1 -> LinkedHashMap k v2
- traverseWithKey :: Applicative f => (k -> v1 -> f v2) -> LinkedHashMap k v1 -> f (LinkedHashMap k v2)
- difference :: (Eq k, Hashable k) => LinkedHashMap k v -> LinkedHashMap k w -> LinkedHashMap k v
- intersection :: (Eq k, Hashable k) => LinkedHashMap k v -> LinkedHashMap k w -> LinkedHashMap k v
- intersectionWith :: (Eq k, Hashable k) => (v1 -> v2 -> v3) -> LinkedHashMap k v1 -> LinkedHashMap k v2 -> LinkedHashMap k v3
- foldl' :: (a -> v -> a) -> a -> LinkedHashMap k v -> a
- foldlWithKey' :: (a -> k -> v -> a) -> a -> LinkedHashMap k v -> a
- foldr :: (v -> a -> a) -> a -> LinkedHashMap k v -> a
- foldrWithKey :: (k -> v -> a -> a) -> a -> LinkedHashMap k v -> a
- filter :: (Eq k, Hashable k) => (v -> Bool) -> LinkedHashMap k v -> LinkedHashMap k v
- filterWithKey :: (Eq k, Hashable k) => (k -> v -> Bool) -> LinkedHashMap k v -> LinkedHashMap k v
- keys :: (Eq k, Hashable k) => LinkedHashMap k v -> [k]
- elems :: (Eq k, Hashable k) => LinkedHashMap k v -> [v]
- toList :: LinkedHashMap k v -> [(k, v)]
- fromList :: (Eq k, Hashable k) => [(k, v)] -> LinkedHashMap k v
- fromListWith :: (Eq k, Hashable k) => (v -> v -> v) -> [(k, v)] -> LinkedHashMap k v
Documentation
data LinkedHashMap k v Source
LinkedHashMap (HashMap k (Entry v)) (IntMap (k, v)) !Int |
Functor (LinkedHashMap k) | |
Foldable (LinkedHashMap k) | |
Traversable (LinkedHashMap k) | |
(Show k, Show v) => Show (LinkedHashMap k v) | |
(NFData k, NFData v) => NFData (LinkedHashMap k v) |
Construction
empty :: LinkedHashMap k v Source
O(1) Construct an empty map.
singleton :: (Eq k, Hashable k) => k -> v -> LinkedHashMap k v Source
O(1) Construct a map with a single element.
Basic interface
size :: LinkedHashMap k v -> Int Source
O(1) Return the number of key-value mappings in this map.
lookup :: (Eq k, Hashable k) => k -> LinkedHashMap k v -> Maybe v Source
O(log n) Return the value to which the specified key is mapped,
or Nothing
if this map contains no mapping for the key.
:: (Eq k, Hashable k) | |
=> v | Default value to return. |
-> k | |
-> LinkedHashMap k v | |
-> 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.
(!) :: (Eq k, Hashable k) => LinkedHashMap k v -> k -> v Source
O(log n) Return the value to which the specified key is mapped.
Calls error
if this map contains no mapping for the key.
insert :: (Eq k, Hashable k) => k -> v -> LinkedHashMap k v -> LinkedHashMap k v Source
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.
insertWith :: (Eq k, Hashable k) => (v -> v -> v) -> k -> v -> LinkedHashMap k v -> LinkedHashMap k v Source
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
delete :: (Eq k, Hashable k) => k -> LinkedHashMap k v -> LinkedHashMap k v Source
O(log n) Remove the mapping for the specified key from this map if present.
adjust :: (Eq k, Hashable k) => (v -> v) -> k -> LinkedHashMap k v -> LinkedHashMap k v Source
O(log n) Adjust the value tied to a given key in this map only if it is present. Otherwise, leave the map alone.
Combine
Union
union :: (Eq k, Hashable k) => LinkedHashMap k v -> LinkedHashMap k v -> LinkedHashMap k v Source
O(m*log n) The union of two maps, n - size of the first map. If a key occurs in both maps, the mapping from the first will be the mapping in the result.
unionWith :: (Eq k, Hashable k) => (v -> v -> v) -> LinkedHashMap k v -> LinkedHashMap k v -> LinkedHashMap k v Source
O(m*log n) The union of two maps, n - size of the first map. If a key occurs in both maps, the provided function (first argument) will be used to compute the result.
unions :: (Eq k, Hashable k) => [LinkedHashMap k v] -> LinkedHashMap k v Source
Construct a set containing all elements from a list of sets.
Transformations
map :: (v1 -> v2) -> LinkedHashMap k v1 -> LinkedHashMap k v2 Source
O(n) Transform this map by applying a function to every value.
mapWithKey :: (k -> v1 -> v2) -> LinkedHashMap k v1 -> LinkedHashMap k v2 Source
O(n) Transform this map by applying a function to every value.
traverseWithKey :: Applicative f => (k -> v1 -> f v2) -> LinkedHashMap k v1 -> f (LinkedHashMap k v2) Source
O(n*log(n)) Transform this map by accumulating an Applicative result from every value.
Difference and intersection
difference :: (Eq k, Hashable k) => LinkedHashMap k v -> LinkedHashMap k w -> LinkedHashMap k v Source
O(n*log m) Difference of two maps. Return elements of the first map not existing in the second.
intersection :: (Eq k, Hashable k) => LinkedHashMap k v -> LinkedHashMap k w -> LinkedHashMap k v Source
O(n*log m) Intersection of two maps. Return elements of the first map for keys existing in the second.
intersectionWith :: (Eq k, Hashable k) => (v1 -> v2 -> v3) -> LinkedHashMap k v1 -> LinkedHashMap k v2 -> LinkedHashMap k v3 Source
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.
Folds
foldl' :: (a -> v -> a) -> a -> LinkedHashMap k v -> a Source
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 -> k -> v -> a) -> a -> LinkedHashMap k v -> a Source
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.
foldr :: (v -> a -> a) -> a -> LinkedHashMap k v -> a Source
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 :: (k -> v -> a -> a) -> a -> LinkedHashMap k v -> a Source
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).
Filter
filter :: (Eq k, Hashable k) => (v -> Bool) -> LinkedHashMap k v -> LinkedHashMap k v Source
O(n*log(n)) Filter this map by retaining only elements which values satisfy a predicate.
filterWithKey :: (Eq k, Hashable k) => (k -> v -> Bool) -> LinkedHashMap k v -> LinkedHashMap k v Source
O(n*log(n)) Filter this map by retaining only elements satisfying a predicate.
Conversions
keys :: (Eq k, Hashable k) => LinkedHashMap k v -> [k] Source
O(n) Return a list of this map's keys. The list is produced lazily.
elems :: (Eq k, Hashable k) => LinkedHashMap k v -> [v] Source
O(n) Return a list of this map's values. The list is produced lazily.
Lists
toList :: LinkedHashMap k v -> [(k, v)] Source
O(n) Return a list of this map's elements.
fromList :: (Eq k, Hashable k) => [(k, v)] -> LinkedHashMap k v Source
O(n*log n) Construct a map with the supplied mappings. If the list contains duplicate mappings, the later mappings take precedence.
fromListWith :: (Eq k, Hashable k) => (v -> v -> v) -> [(k, v)] -> LinkedHashMap k v Source
O(n*log n) Construct a map from a list of elements. Uses the provided function to merge duplicate entries.