A multidimensional map class

版本 1.1.0.0 (9.2 KB) 作者: David Young
MapN provides a map class similar to containers.Map, but with multidimensional keys.
997.0 次下载
更新时间 2014/6/30

查看许可证

MapN provides a multidimensional map container.

A MapN object contains key lists and values. A value is some unit of data that you want stored in the MapN object, and a key list is a unique reference to that data.

MapN is modelled on containers.Map, but whereas a containers.Map object is indexed by a single scalar or string key, a MapN object is indexed by an ordered set of such keys, expressed as a comma-separated list of arguments.

A MapN object is constructed like this:

M = MapN();

Values are stored using M(key1, key2, ...) = value, for example:

M(1, 'a') = 'a string value';
M(1, 'b') = 287.2;
M(2) = [1 2 3; 4 5 6];
M(2, 'x', pi) = {'a' 'cell' 'array'};

and values are retrieved using M(key1, key2, ...), for example

v = M(1, 'b');
u = M(2);

This contribution also includes a memoize function, inspired by the blog entry at http://blogs.mathworks.com/loren/2006/02/08/use-nested-functions-to-memoize-costly-functions/ The memoize function demonstrates one use of MapN.

引用格式

David Young (2024). A multidimensional map class (https://www.mathworks.com/matlabcentral/fileexchange/33068-a-multidimensional-map-class), MATLAB Central File Exchange. 检索时间: .

MATLAB 版本兼容性
创建方式 R2013b
兼容任何版本
平台兼容性
Windows macOS Linux
类别
Help CenterMATLAB Answers 中查找有关 Dictionaries 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
版本 已发布 发行说明
1.1.0.0

Fixed bug in remove method. My thanks to Xiaohu for reporting the bug.

1.0.0.0