// 文字列を順次ストックしていき、その文字列を探す。 // setのメンバfindを使うと速い。 #include <iostream> #include <string> #include <set> using namespace std; int main( ) { set<string,less<string> > stringSet; stringSet.insert( "hogehoge" ); stringSet.insert( "foo" ); stringSet.insert( "bar" ); // このサーチが一番速い( O(log(n) ) set<string,less<string> >::iterator itr = stringSet.find( "foo" ); if ( itr != stringSet.end( ) ) { cout << "I's found " << *itr << endl; } return 0; } /* find( setObj.begin(), setObj.end(), "hogehoge" ); も使えるが、O(n) なので遅い。 コーディングも楽して、いい結果が得られる(^^ */ // end of file