Code covered by the BSD License  

Highlights from
A multidimensional map class

Be the first to rate this file! 11 Downloads (last 30 days) File Size: 9.92 KB File ID: #33068

A multidimensional map class

by David Young

 

29 Sep 2011

MapN provides a map class similar to containers.Map, but with multidimensional keys.

| Watch this File

File Information
Description

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.

MATLAB release MATLAB 7.12 (R2011a)
Tags for This File  
Everyone's Tags
container, containers, containersmap, map, memoize, multidimensional, oop
Tags I've Applied
Add New Tags Please login to tag files.
Please login to add a comment or rating.

Contact us