How to use matlab container.map?

6 次查看(过去 30 天)
Patrick Mboma
Patrick Mboma 2012-10-20
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.

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Lighting, Transparency, and Shading 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by