ADS
Algorithms and Data Structures
Loading...
Searching...
No Matches
ADS::Dictionary Concept Reference

DICTIONARY (section 3.2.3): a univocal relation from keys to values; lookup() returns the value of a key, or nothing (the nil of the book, std::nullopt). More...

#include <ADS/ADT.h>

Concept definition

template< class D >
concept Dictionary = requires( D d , const D cd , const typename D::Key & k ,
const typename D::Value & v )
{
typename D::Key;
typename D::Value;
{ cd.lookup( k ) } -> std::same_as< std::optional< typename D::Value > >;
d.insert( k , v );
d.remove( k );
}
DICTIONARY (section 3.2.3): a univocal relation from keys to values; lookup() returns the value of a ...
Definition ADT.h:161

Detailed description

DICTIONARY (section 3.2.3): a univocal relation from keys to values; lookup() returns the value of a key, or nothing (the nil of the book, std::nullopt).

As axioms, \( \mathrm{lookup}( k , \mathrm{create} ) = \mathbf{nil} \), \( \mathrm{lookup}( k , \mathrm{insert}( k' , v , D ) ) \) is \( v \) if \( k = k' \) and \( \mathrm{lookup}( k , D ) \) otherwise (inserting a key already there replaces its value), \( \mathrm{lookup}( k , \mathrm{remove}( k' , D ) ) \) is \( \mathbf{nil} \) if \( k = k' \) and \( \mathrm{lookup}( k , D ) \) otherwise; lookup() and remove() are total, i.e., they do not need the key to be there