Functional Dictionaries

Denys Duchier

module
x-oz://system/adt/Dictionary.ozf

This module provides functional interface for dictionaries

Exports

The module exports the following constructors:

{Dictionary.new ?D}
returns a new empty functional dictionary D
{Dictionary.newFromRecord +R ?D}
returns a new functional dictionary D initialized using the key/value mapping provided by record R

Instance API

Each functional dictionary instance D has the following features:

{D.get +Key ?Value}
returns the Value for the given Key, or raises an exception if none
{D.put +Key +Value}
sets the Value for the given Key
{D.condGet +Key +Default ?Value}
returns the Value for the given Key, or the Default if none
{D.reset}
remove all entries
{D.keys ?L}
returns the list L of all keys in D
{D.items ?L}
returns the list L of all values in D
{D.entries ?L}
returns the list L of all pairs Key#Values for entries in D
{D.isEmpty ?B}
returns true iff D is empty
{D.remove +Key}
remove the entry for Key if any
{D.member +Key ?B}
returns true iff there is an entry for Key
{D.clone ?D2}
returns a new functional dictionary instance D2 that is a clone of D
{D.toRecord +L ?R}
return the current entries in D in the form of a record R with label L