From: Joao Henriques on
Almost all of my Matlab work is done using arrays, sparse arrays and cell arrays. Only recently have I found a natural application for containers.Map, and I was pretty excited to explore this relatively new tool.

However, a few missing features are making it hard to work with. First, there's no way to create a new, empty Map and specify its KeyType/ValueType -- the Map is initialized with the default types ('char'/'any'), and if I want to index values by 'double' or something, I can't. The annoying workaround is to initialize it with a dummy pair of the types I want, then delete it (hardly elegant, but I can do that while waiting for the fix).

This behavior must be very confusing for someone not willing to dig deeper into the issue, and can be one of the factors that explains the slow adoption of the Map class; since the new user is greeted with an error when trying a simple operation :)

Secondly, the documentation has a section "Modifying a Copy of the Map", which says that Map assignments only take the reference, instead of making a copy. There must be a method to make a copy of the Map (right?); the documentation isn't very helpful in this regard, as copying by value is a pretty standard operation. (I'm not suggesting that the behavior of the assignment operation should be changed, only that a copy method be added or referenced in the docs.)

Also, it seems surprising that character arrays can be hashed, but for instance double arrays cannot. This feature would be very appreciated, although I can live without it of course.

And continuing with the "containers" idea, some algorithms require a vector/cell array that supports fast insertions and deletions (say, a list of active kalman filters for tracking). Right now I'm trying to use the Map for this effect (then do a little benchmarking to see if it's worth it vs. simple vectors/matrices, by saving the memory allocs/deallocs when resizing), but in the future it would be nice to have a List container to complement the Map.

Anyway, just pointing out some issues since with any new feature there's always room for improvement. The first two are essential in my opinion, the last two are just "nice-to-have" 's. Many thanks to the Matlab team for their hard work :)
From: EBS on
"Joao Henriques" <remove_this_part_jotaf98(a)hotmail.com> wrote in message <hp2i5d$pj9$1(a)fred.mathworks.com>...
> Almost all of my Matlab work is done using arrays, sparse arrays and cell arrays. Only recently have I found a natural application for containers.Map, and I was pretty excited to explore this relatively new tool.
>
> However, a few missing features are making it hard to work with. First, there's no way to create a new, empty Map and specify its KeyType/ValueType -- the Map is initialized with the default types ('char'/'any'), and if I want to index values by 'double' or something, I can't. The annoying workaround is to initialize it with a dummy pair of the types I want, then delete it (hardly elegant, but I can do that while waiting for the fix).

That does seem odd...

>
> This behavior must be very confusing for someone not willing to dig deeper into the issue, and can be one of the factors that explains the slow adoption of the Map class; since the new user is greeted with an error when trying a simple operation :)
>
> Secondly, the documentation has a section "Modifying a Copy of the Map", which says that Map assignments only take the reference, instead of making a copy. There must be a method to make a copy of the Map (right?); the documentation isn't very helpful in this regard, as copying by value is a pretty standard operation. (I'm not suggesting that the behavior of the assignment operation should be changed, only that a copy method be added or referenced in the docs.)

I can't see any doc about this either.

>
> Also, it seems surprising that character arrays can be hashed, but for instance double arrays cannot. This feature would be very appreciated, although I can live without it of course.

Agreed.

>
> And continuing with the "containers" idea, some algorithms require a vector/cell array that supports fast insertions and deletions (say, a list of active kalman filters for tracking). Right now I'm trying to use the Map for this effect (then do a little benchmarking to see if it's worth it vs. simple vectors/matrices, by saving the memory allocs/deallocs when resizing), but in the future it would be nice to have a List container to complement the Map.

Agreed, I've love to have a List, Deque, Stack, Tree, etc :)
>
> Anyway, just pointing out some issues since with any new feature there's always room for improvement. The first two are essential in my opinion, the last two are just "nice-to-have" 's. Many thanks to the Matlab team for their hard work :)

Please send your feedback directly to Tech Support. Posts to the newsgroup don't have the weight of feedback officially recorded in the bug/enhancement database, which is what is used to prioritize features for implementation.

Cheers!
From: EBS on
"Joao Henriques" <remove_this_part_jotaf98(a)hotmail.com> wrote in message <hp2i5d$pj9$1(a)fred.mathworks.com>...
> Almost all of my Matlab work is done using arrays, sparse arrays and cell arrays. Only recently have I found a natural application for containers.Map, and I was pretty excited to explore this relatively new tool.
>
>(snip)
> Anyway, just pointing out some issues since with any new feature there's always room for improvement. The first two are essential in my opinion, the last two are just "nice-to-have" 's. Many thanks to the Matlab team for their hard work :)

Here's a post describing a feature that I feel is missing, what do you think?
http://www.mathworks.com/matlabcentral/newsreader/view_thread/244296#627675

If you agree, please contact TMW tech support and ask to add a feature request for this (it might already exist in the database, I can't remember if I called them about it or not).


Hi all,

is there any reason why the following syntax does not work?

>> keys = {'test1' 'test2' 'test3'};
>> values = {1 2 3};
>> myMap = containers.Map(keys,values);
>> dataKeys = {'test1' 'test3'};
>> data1 = myMap(dataKeys{1}) % this works, with a scalar string input.
>> data2 = myMap.values(dataKeys) % this works, but extra typing rel. to below.
>> data3 = myMap(dataKeys) % this does not work.
??? Error using ==> subsref
Specified key type does not match the type expected for this container.

It would seem to be a valid syntax - it's unique from the existing documented syntax and thus could be parsed (because it's a single cell array instead of a scalar), and it would be handy for the user because it's shorter than using the values method and seems very natural.
From: Joao Henriques on
"EBS " <ericDOTsampson(a)gmail.com> wrote in message <hp36ht$knm$1(a)fred.mathworks.com>...
> Please send your feedback directly to Tech Support. Posts to the newsgroup don't have the weight of feedback officially recorded in the bug/enhancement database, which is what is used to prioritize features for implementation.

Yes, I'm going to do that just now. This is one of those things that could be extremely handy, and as we develop ever more complex Matlab programs we start to miss some data structures that are common in other languages.

> "Joao Henriques" <remove_this_part_jotaf98(a)hotmail.com> wrote in message <hp2i5d$pj9$1(a)fred.mathworks.com>...
> > And continuing with the "containers" idea, some algorithms require a vector/cell array that supports fast insertions and deletions (say, a list of active kalman filters for tracking). Right now I'm trying to use the Map for this effect (then do a little benchmarking to see if it's worth it vs. simple vectors/matrices, by saving the memory allocs/deallocs when resizing), but in the future it would be nice to have a List container to complement the Map.
>
> Agreed, I've love to have a List, Deque, Stack, Tree, etc :)

Sure, although the Tree could be a bit of a tall order compared to the rest!

List, Deque, Stack -- they can all be collapsed into a single List, with appropriate [push/pop]_[back/front] methods, if it's implemented as a standard doubly-linked-list with back and front pointers. Having just a List would be a big improvement, although first I'd like the Map to receive a little more attention :)
From: Joao Henriques on
"EBS " <ericDOTsampson(a)gmail.com> wrote in message <hp36pv$o34$1(a)fred.mathworks.com>...
> It would seem to be a valid syntax - it's unique from the existing documented syntax and thus could be parsed (because it's a single cell array instead of a scalar), and it would be handy for the user because it's shorter than using the values method and seems very natural.

Well, usually, only vectors are used when indexing multiple elements, since each index is a scalar number. Since an index in the context of a Map can be non-scalar, and a "vector" of non-scalar things is a cell array, multiple-indexing requires cell arrays. So yes, it makes sense, although the Map is a very special case in this regard! :)
 |  Next  |  Last
Pages: 1 2
Prev: Vectorize This
Next: Integration square