【C++】template 統合スレ -- Part3
■ このスレッドは過去ログ倉庫に格納されています
0041デフォルトの名無しさん
NGNGclass IndexMap
{
typedef std::map<AnsiString, int> map_type;
map_type m_map;
public:
int operator()( const AnsiString& ext ) {
map_type::iterator const bound = m_map.lower_bound( ext );
if ( bound != m_map.end() && !m_map.key_comp()( ext , bound->first ) ) {
return bound->second; // すでに登録されている
}
// 新しく登録
int const index = m_map.size();
m_map.insert( bound , map_type::value_type( ext , index ) );
return index;
}
};
で、インデックスは連番でいいのかな?
■ このスレッドは過去ログ倉庫に格納されています