Listing B
// Easily -> 3, collections -> 12, write -> 5 std::cout << coll_container( collWords); // Easily -> 3 // collections -> 12 // write -> 5 std::cout << coll_container( collWords, formatter( coll_transform( "%k -> %v"), "\n")); // [Easily] -> [3]; // [collections] -> [12]; // [write] -> [5]. std::cout << coll_container( collWords, formatter( coll_transform( "[%k] -> [%v]"), "", ";\n", ".")); // Key: Easily, Value: 3; // Key: collections, Value: 12; // Key: write, Value: 5. std::cout << coll_container( collWords, formatter( coll_transform( "Key: %k, Value: %v"), "", ";\n", ".")); // Word 'Easily' appeared 3 time(s). // Word 'collections' appeared 12 time(s). // Word 'write' appeared 5 time(s). std::cout << coll_container( collWords, formatter( coll_transform( "Word '%k' appeared %v time(s)."), "\n")); // (note that after each element, we write ';' // but after the last element, we write '.') // // Word 'Easily' appeared 3 time(s); // Word 'collections' appeared 12 time(s); // Word 'write' appeared 5 time(s). std::cout << coll_container( collWords, formatter( coll_transform( "Word '%k' appeared %v time(s)"), "", ";\n", ".")); // Word 'EASILY' appeared 3 time(s); // Word 'COLLECTIONS' appeared 12 time(s); // Word 'WRITE' appeared 5 time(s). std::cout << coll_container( collWords, formatter( coll_transform( "Word '%k' appeared %v time(s)", KeyToUpper()), "", ";\n", ".")); // [0] Word 'Easily' appeared 3 time(s); // [1] Word 'collections' appeared 12 time(s); // [2] Word 'write' appeared 5 time(s). std::cout << coll_container( collWords, formatter( coll_transform( "Word '%k' appeared %v time(s)", PrefixByIndex()),