vector는 특정데이터만 찝어내는 검색속도가 느리다.

이런경우에 set컨테이너가 안성맞춤이다(이진트리방식 채용 상대적으로 검색속도 빠름)

아래 샘플소스는 c++11이상에서 지원된다.


using namespace std;

...


bool ClassNamer::isMyDevice(string findDevice, string parentDevice)

{

const set<string> savedList = mDataSet;


if (savedList.size() == 0)

return false;


if ((savedList.find(findDevice) != savedList.end()))

return true;


if ((savedList.find(parentDevice) != savedList.end()))

return true;


return false;

}

+ Recent posts