기본 콘텐츠로 건너뛰기

std::set::iterator는 const_iterator이다.

std::map은 Key를 기반으로 B-Tree(정확히는 Red Black Tree/RB-Tree)를 구성한다.

이때, Key를 수정하려면, 트리구조 근간을 흔들어야 하므로, Key는 반드시 const로 보호한다. (수정하고 싶으면 erase한 뒤에, insert를 다시 해야한다.)

std::set은 Key로만 구성한 B-Tree이다. 당연히 std::map처럼 Key를 const로 보호해야하므로, std::set::iterator는 수정 권한이 없는 std::set::const_iterator이다.

* 참조: http://www.cplusplus.com/reference/set/set/
* 참조: 왜 STL은 RB-tree를 쓰는가? http://stackoverflow.com/questions/5288320/why-is-stdmap-implemented-as-red-black-tree

댓글

이 블로그의 인기 게시물

탐색기에서 OneDrive 이 2개로 보이는 문제

왜 2개가 보이는지 모르겠지만, Registry 삭제하면 됨 HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Desktop\NameSpace 하위 키에서 OneDrive 둘 중에 하나만 지워도 바로 반영됨. 참조:  https://answers.microsoft.com/en-us/msoffice/forum/all/duplicate-onedrives-in-file-explorer/49c935a6-287b-43a5-aed5-2dee2a1c1b22