필터 지우기
필터 지우기

Get Unique Instance Identifier

조회 수: 7 (최근 30일)
Jonas Reber
Jonas Reber 2011년 5월 3일
Hello MatLabers
How do I get the unique object identifier of an object (i.e. the handle)?
I have several objects in a cell array (lets call it OArr) of Class MyClass (which is a handle class) and would like to create a hashtable (java.utils.Hashtable) with the object identifier of each object in OArr as key and assign it some data. (user for a match table)
I don't want to take the whole objects or any of their properties as there might exist several objects with the same property values. I also do not want to add another cell-column to the OArr. Thats why i thought the unique identifier (mem location?) would be a good idea...?
Thank you very much!

답변 (1개)

Matt Tearle
Matt Tearle 2011년 5월 3일
Dumb question: why can't you just use the cell index?
  댓글 수: 2
Jonas Reber
Jonas Reber 2011년 5월 3일
because I randomly add and remove cells from that cell array (random positions) - then, at every insert/deletion i would have to renumber both arrays.
Matt Tearle
Matt Tearle 2011년 5월 4일
Ah. Fair enough. In that case, it's tricky. AFAIK, there's no easy way to get the memory reference of an object. Maybe you could make a meta-variable of identifiers (using sequential number or something like that). Sorry I don't have any better ideas.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Dictionaries에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by