How to use matlab container.map?

3 visualizaciones (últimos 30 días)
Patrick Mboma
Patrick Mboma el 20 de Oct. de 2012
Hi all, I have the following problem. I have a potentially large number of objects. The objects are the nodes of a tree. Each branch stems from a node and can generate a node with further branches. There are several trees and the thing is that several trees may have some of their nodes that are identical. I would like to flag each node in such a way that all identical nodes in different trees (and branches) have the same reference. I would like to put a reference only on the nodes that are re-used.
Here is a lousy example with its solution:
tree(1).nodes={a,b,c}; tree(2).nodes= {b,c,d,e};
tree(1).refs={'','r1','r2'}; tree(2).refs= {'r1','r2','',''};
In the first stage, when constructing tree(1), the references are empty since none of the nodes (in this simple example) is re-used. But then when constructing tree(2), realizing that b and c where already computed, they are flagged.
I was told I should be looking for hash tables or hash maps and I found out that the equivalent in matlab is the class container.map. But I do not understand how to use it or at least in a way that solves my problem.
Can someone help? Thanks,
Pat.

Respuestas (0)

Categorías

Más información sobre Object Containers en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by