I have a need for hashmap-like functionality in Matlab, where the hashmap maps vectors to other vectors, and the number of vectors (ranging in the hundreds of thousands) is not known beforehand.
I tried Matlab's inbuilt Containers.Map, but that doesn't accept vectors as keys. Then I tried java.util.HashMap:
>> map = java.util.HashMap;
>> map.put(1:3,zeros(2,1));
>> map.get(1:3)
ans =
[]
So for some reason that doesn't seem to work, even though Java's HashMap should be able to map arrays to arrays.
The other option would be to keep two separate matrices, one for the keys and one for the values, and grow them incrementally. But I don't want really want to do that because of the pain in Matlab of growing things incrementally (even with block-size increments etc, e.g. here).
Questions: 1. Why doesn't Java's HashMap work here? 2. Any other approaches?
Thanks.