multimap-1.2.1: A multimap.

Safe Haskell | Safe-Inferred
Language | Haskell2010

Data.SetMap

Contents

- SetMap type
- Query
- Operators
- Construction
  - Insertion
  - Deletion
- Traversal
- Conversion

Synopsis

- data SetMap k v
- null :: SetMap k a -> Bool
- size :: SetMap k a -> Int
- numKeys :: SetMap k a -> Word32
- numValues :: SetMap k a -> Word32
- member :: Ord k => SetMap k a -> k -> Bool
- notMember :: Ord k => SetMap k a -> k -> Bool
- lookup :: Ord k => k -> SetMap k a -> Set a
- (!) :: Ord k => SetMap k a -> k -> Set a
- empty :: SetMap k a
- insert :: (Ord k, Ord a) => k -> a -> SetMap k a -> SetMap k a
- delete :: Ord k => k -> SetMap k a -> SetMap k a
- map :: (Ord a, Ord b) => (a -> b) -> SetMap k a -> SetMap k b
- elems :: SetMap k a -> [[a]]
- keys :: SetMap k a -> [k]
- toMap :: SetMap k a -> Map k (Set a)

# SetMap type

data SetMap k v Source #

A SetMap with keys `k` and values `v`.

#### Instances

Instances details

(Data k, Data v, Ord v, Ord k) => Data (SetMap k v) Source # |

Instance details

Defined in Data.SetMap

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> SetMap k v -> c (SetMap k v) Source #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c (SetMap k v) Source #

toConstr :: SetMap k v -> Constr Source #

dataTypeOf :: SetMap k v -> DataType Source #

dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c (SetMap k v)) Source #

dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (SetMap k v)) Source #

gmapT :: (forall b. Data b => b -> b) -> SetMap k v -> SetMap k v Source #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> SetMap k v -> r Source #

gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> SetMap k v -> r Source #

gmapQ :: (forall d. Data d => d -> u) -> SetMap k v -> [u] Source #

gmapQi :: Int -> (forall d. Data d => d -> u) -> SetMap k v -> u Source #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> SetMap k v -> m (SetMap k v) Source #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> SetMap k v -> m (SetMap k v) Source #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> SetMap k v -> m (SetMap k v) Source #

# Query

null :: SetMap k a -> Bool Source #

O(1). Check whether the multimap is empty or not.

size :: SetMap k a -> Int Source #

O(1). The number of elements in the multimap.

numKeys :: SetMap k a -> Word32 Source #

O(1). The number of keys in the multimap.

As this is a multimap, the number of keys is not necessarily equal to the number of values.

numValues :: SetMap k a -> Word32 Source #

O(1). The number of values in the multimap.

As this is a multimap, the number of keys is not necessarily equal to the number of values.

member :: Ord k => SetMap k a -> k -> Bool Source #

O(log n). Is the key a member of the multimap?

notMember :: Ord k => SetMap k a -> k -> Bool Source #

O(log n). Is the key not a member of the multimap?

lookup :: Ord k => k -> SetMap k a -> Set a Source #

O(log n). Lookup the value at a key in the map.

The function will return the corrsponding values as a List, or the empty list if no values are associated witht the given key.

# Operators

(!) :: Ord k => SetMap k a -> k -> Set a Source #

As `flip lookup`

# Construction

empty :: SetMap k a Source #

O(1). The empty multimap.

## Insertion

insert :: (Ord k, Ord a) => k -> a -> SetMap k a -> SetMap k a Source #

Insert a new key and value in the map.

## Deletion

delete :: Ord k => k -> SetMap k a -> SetMap k a Source #

Delete a key and all its values from the map.

# Traversal

map :: (Ord a, Ord b) => (a -> b) -> SetMap k a -> SetMap k b Source #

Map a function over all values in the map.

# Conversion

elems :: SetMap k a -> [[a]] Source #

Return all elements of the multimap in the ascending order of their keys.

A list of lists is returned since a key can have multiple values. Use `concat` to flatten.

keys :: SetMap k a -> [k] Source #

O(n). Return all keys of the multimap in ascending order.

toMap :: SetMap k a -> Map k (Set a) Source #

O(1). Return the map of sets.