☰

*ON THIS PAGE*# Dictionaries

**Author(s):** The Ciao Development Team.## Usage and interface

## Documentation on exports

## Documentation on imports

This module has the following direct dependencies:

This module provides predicates for implementing dictionaries. Such dictionaries are currently implemented as ordered binary trees of key-value pairs.

**Library usage:**`:- use_module(library(dict)).`**Exports:***Predicates:*`dictionary/5`,`dic_node/2`,`dic_lookup/3`,`dic_lookup/4`,`dic_get/3`,`dic_replace/4`.*Regular Types:*`dictionary/1`,`old_or_new/1`,`non_empty_dictionary/1`.

REGTYPEdictionary/1

Usage:`dictionary(D)`

D is a dictionary.

PREDICATEdictionary/5

Usage:`dictionary(D,K,V,L,R)`

The dictionary node D has key K, value V, left child L, and right child R.

*The following properties should hold upon exit:*

(`dict:non_empty_dictionary/1`)D is a non-empty dictionary.

PREDICATEdic_node/2

Usage:`dic_node(D,N)`

N is a sub-dictionary of D.

*The following properties should hold at call time:*

(`dict:non_empty_dictionary/1`)D is a non-empty dictionary.*The following properties should hold upon exit:*

(`dict:dictionary/1`)N is a dictionary.

PREDICATEdic_lookup/3

Usage:`dic_lookup(D,K,V)`

D contains value V at key K. If it was not already in D it is added.

*The following properties should hold upon exit:*

(`dict:non_empty_dictionary/1`)D is a non-empty dictionary.

PREDICATEdic_lookup/4

Usage:`dic_lookup(D,K,V,O)`

Same as `dic_lookup(D,K,V)`. O indicates if it was already in D (`old`) or not (`new`).

*The following properties should hold upon exit:*

(`dict:non_empty_dictionary/1`)D is a non-empty dictionary.

(`dict:old_or_new/1`)`dict:old_or_new(O)`

PREDICATEdic_get/3

Usage:`dic_get(D,K,V)`

D contains value V at key K. Fails if it is not already in D.

*The following properties should hold at call time:*

(`term_typing:nonvar/1`)D is currently a term which is not a free variable.

(`dict:dictionary/1`)D is a dictionary.*The following properties should hold upon exit:*

(`dict:non_empty_dictionary/1`)D is a non-empty dictionary.

PREDICATEdic_replace/4

Usage:`dic_replace(D,K,V,D1)`

D and D1 are identical except for the element at key K, which in D1 contains value V, whatever has (or whether it is) in D.

*The following properties should hold at call time:*

(`dict:dictionary/1`)D is a dictionary.

(`dict:dictionary/1`)D1 is a dictionary.*The following properties should hold upon exit:*

(`dict:dictionary/1`)D is a dictionary.

(`dict:dictionary/1`)D1 is a dictionary.

REGTYPEold_or_new/1

A regular type, defined as follows:

old_or_new(old). old_or_new(new).

REGTYPEnon_empty_dictionary/1

Usage:`non_empty_dictionary(D)`

D is a non-empty dictionary.

*Packages:*`prelude`,`initial`,`condcomp`,`assertions`,`assertions/assertions_basic`,`nortchecks`,`isomodes`.

Generated with LPdoc using Ciao