Index
MultiRecord
This functor defines a multi-dimensional extendable record data structure (quasi a stateless dictionary, implemented by RecordC). The key to a value in a multi-dimensional record is a list Keys whose values are any combination of integers, atoms and names.
This is a stateless data structure (and can therefore be used, e.g., in a CSP such that it is defined globally and 'changed' in the CSP). There is only one stateful operation: Clear (changes binding of cell created by New).

NOTE: This implementation is not thread-save: checking whether a key is valid and putting a value at the key is not atomic. Using locks would limit the use of this data structure in a CSP..

NOTE: efficiency only linear time in worst case (depending on number of features of Rec), but thats the best I can do (currently, there is not RecordC.reflectHasFeature, only RecordC.reflectArity and thus the list of all currently stored keys must be searched in a tmp def of ReflectHasFeature defined here).

Functor

Import

Export

Define

proc{NewR X}
Returns a new empty multi-dimensional record.


proc{Clear X}
Completely empties the record X.


fun{Is X}
Tests whether X is a multi-dimensional record.


fun{ReflectHasFeat Rec Keys}
Tests whether Rec has the multi-dimensional feature Keys.
NB: no thread-save definition.


fun{Get Rec Keys}
Returns the item in Rec at Keys.


fun{CondGet Rec Keys DefVal}
Returns the item in Rec at Keys if Keys is valid, otherwise DefVal is retured.
NB: no thread-save definition.


fun{CondGetPutting Rec Keys Fn}
Returns the item in Rec at Keys if Keys is valid, otherwise put result of nullary Fn at Keys and return that.
NB: no thread-save definition.


proc{Put Rec Keys X}
Sets the item in Rec under Keys to X.
NB: no thread-save definition.


fun{Entries Rec}
Returns the list of current entries of Rec. An entry is a pair Keys#X, where Keys is a list and X the corresponding item.


End