C++ count and map

前端 未结 5 1121
难免孤独
难免孤独 2021-01-22 21:54

I am counting the number of times every word occurs in a text file. I would like to avoid cases and hence am doing tolower to my input and then counting. I have a map data struc

5条回答
  •  滥情空心
    2021-01-22 22:42

    What do you want to happen with different case variants of the same word?

    One possibility is to use std::multiset with a caseless comparator as its Compare template parameter. In this case, all variants of each word will be preserved in the set. Number of occurrences of each word can be obtained via count() member function of the set.

提交回复
热议问题