Module da_map

It implements a double associative map.

Copyright © (C) 2015, Pablo Lamela, Simon Thompson

Authors: Pablo Lamela Seijas (P.Lamela-Seijas@kent.ac.uk), Simon Thompson (S.J.Thompson@kent.ac.uk).

Description

It implements a double associative map. It is a key-value storage that can be queried through both the key and the value.

Data Types

da_map()

abstract datatype: da_map(Key, Value)

Function Index

delete_by_key/2 Remove the entry with Key as key from the DaMap if it exists.
delete_by_value/2 Remove the entry with Value as value from the DaMap if it exists.
find_key/2 Returns {ok, Key} if there is an entry with Value as value in the da_map, returns error otherwise.
find_value/2 Returns {ok, Value} if there is an entry with Key as key in the da_map, returns error otherwise.
fold/3 Folds the function Fun through all the entries of the DaMap.
has_key/2 Returns true if there is an entry with Key as key in the da_map, returns false otherwise.
has_pair/3 Returns true if there is an entry with Key as key and Value as value in the DaMap, returns false otherwise.
has_value/2 Returns true if there is an entry with Value as value in the DaMap, returns false otherwise.
new/0 It creates an empty da_map.
put/3 Stores an entry with Key as key and Value as value in the DaMap.
size/1 Returns the number of entries of the DaMap.
union/2 Joins DaMap1 and DaMap2 by inserting all the entries of DaMap2 in DaMap1.

Function Details

delete_by_key/2

delete_by_key(Key, DaMap::da_map(Key, Value)) -> da_map(Key, Value)

Remove the entry with Key as key from the DaMap if it exists.

delete_by_value/2

delete_by_value(Value, DaMap::da_map(Key, Value)) -> da_map(Key, Value)

Remove the entry with Value as value from the DaMap if it exists.

find_key/2

find_key(Value, DaMap::da_map(Key, Value)) -> {ok, Key} | error

Returns {ok, Key} if there is an entry with Value as value in the da_map, returns error otherwise.

find_value/2

find_value(Key, DaMap::da_map(Key, Value)) -> {ok, Value} | error

Returns {ok, Value} if there is an entry with Key as key in the da_map, returns error otherwise.

fold/3

fold(Fun, AccIn::Acc, DaMap::da_map(Key, Value)) -> AccOut::Acc

Folds the function Fun through all the entries of the DaMap.

See also: dict:fold/3.

has_key/2

has_key(Key, DaMap::da_map(Key, any())) -> boolean()

Returns true if there is an entry with Key as key in the da_map, returns false otherwise.

has_pair/3

has_pair(Key, Value, DaMap::da_map(Key, Value)) -> boolean()

Returns true if there is an entry with Key as key and Value as value in the DaMap, returns false otherwise.

has_value/2

has_value(Value, DaMap::da_map(any(), Value)) -> boolean()

Returns true if there is an entry with Value as value in the DaMap, returns false otherwise.

new/0

new() -> da_map(any(), any())

It creates an empty da_map.

put/3

put(Key, Value, DaMap::da_map(Key, Value)) -> da_map(Key, Value)

Stores an entry with Key as key and Value as value in the DaMap. It removes all existing entries with Key as key or Value as value.

size/1

size(DaMap::da_map(any(), any())) -> non_neg_integer()

Returns the number of entries of the DaMap.

union/2

union(DaMap1::da_map(Key, Value), DaMap2::da_map(Key, Value)) -> da_map(Key, Value)

throws da_maps_not_disjoint

Joins DaMap1 and DaMap2 by inserting all the entries of DaMap2 in DaMap1. It assumes DaMap1 and DaMap2 are disjoint in terms of both their keys and their values. It throws da_maps_not_disjoint if DaMap1 and DaMap2 are not disjoint in terms of keys or values.


Generated by EDoc, Nov 5 2015, 16:30:19.