19 #include <unordered_map> 23 int main(
int argc,
char* argv[]) {
25 std::cerr <<
"Usage: " << argv[0] <<
" <files>" << std::endl;
31 std::unordered_map<std::string, size_t> count_map;
33 for (
int argi = 1; argi < argc; ++argi) {
35 std::ifstream in(argv[argi]);
37 std::cerr <<
"Could not open " << argv[argi] << std::endl;
42 while (std::getline(in, line,
'\n'))
46 if (sv.
size() == 0)
return;
52 std::cerr <<
"word_counting done: " << timer <<
" s" << std::endl;
54 for (
auto& p : count_map) {
55 std::cout << p.first <<
": " << p.second << std::endl;
58 std::cerr <<
"after output: " << timer <<
" s" << std::endl;
int main(int argc, char *argv[])
size_t size() const noexcept
Returns the size of this StringView.
std::basic_string< char, std::char_traits< char >, Allocator< char > > string
string with Manager tracking
StringView is a reference to a part of a string, consisting of only a char pointer and a length...
std::string to_string() const
Returns the data of this StringView as a std::string.
static void split_view(char sep, const std::string &str, Functor &&callback, std::string::size_type limit=std::string::npos)
Split the given string at each separator character into distinct substrings, and call the given callb...