|
ADS
Algorithms and Data Structures
|
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>
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