필터 지우기
필터 지우기

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