Get index of element in C++ map
Get index of element in C++ map
I have a std::map called myMap in my C++ application, and I want to get an element using either myMap.find(key) or myMap[key]. However, I would also like to get the index of that element in the map...
stackoverflow.com
int k = distance(mymap.begin(), mymap.find(mykey));
'Algorithm ๐ง๐ปโ๐ป > Note' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[C++, ํ ํ๋ฆฟ] ๋ฐฐ์ด ๋๋ฆฌ๊ธฐ์ ๋ฌํฝ์ด ๋ฐฐ์ด (0) | 2022.09.22 |
---|---|
๋นํธ๋ง์คํฌ(BitMask) (0) | 2022.09.16 |
[C++, ํ ํ๋ฆฟ] ์ ๋์จ ํ์ธ๋ (0) | 2022.09.02 |
[C++, ํ ํ๋ฆฟ] ๋ค์ต์คํธ๋ผ (0) | 2022.05.28 |
[C++, ํ ํ๋ฆฟ] ํ๋ก์ด๋-์์ฌ (0) | 2022.05.13 |
[C++, ์ ์ฉํ ๋ฌธ๋ฒ] upper_bound, lower_bound (0) | 2022.05.11 |
๋๊ธ