필터 지우기
필터 지우기

Is there a function in matlab that is equivalent to STL multimap in C++

조회 수: 13 (최근 30일)
hello_matlab
hello_matlab 2014년 7월 29일
답변: Nir Rattner 2014년 8월 6일
I know there is container.Map in matlab that is equivalent to STL map in C++. How about C++ STL mulmap that could allow duplicated key values, is there equivalent one in matlab?

답변 (1개)

Nir Rattner
Nir Rattner 2014년 8월 6일
I could not find a direct equivalent to STL multimap in MATLAB, however, you can use cell arrays with two columns to make key-value pairs that are functionally the same.
C++:
std::multimap<std::string, int> m;
m.insert(std::pair<std::string,int>(key1, 1));
m.insert(std::pair<std::string,int>(key2, 1));
m.insert(std::pair<std::string,int>(key2, 2));
m.insert(std::pair<std::string,int>(key3, 1));
MATLAB:
m={'key1', 1; 'key2', 1; 'key2', 2; 'key3', 1};

카테고리

Help CenterFile Exchange에서 STL (STereoLithography)에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by