People i sighed in

std::unordered_map<std::string, std::vector<Movie>> MovieByTitel 

Movie object that matters such as Title, year of release, director. And it is necessary that the program asks "Find a Movie:" and one could enter the first couple of characters of the movie name and the program would give out all the movies in the names of which there are combinations of these characters. In general, I do not know how to make a match spell in the title and pull out all these films from the map

    1 answer 1

    Standard ways to quickly do this in unordered_map do not. I understand you need either a regular map and use lower_bound in it or write bor (dictionary tree) yourself.

    unordered_map uses hash tables so the first letter information is not available. Of course you can go through the whole collection but you can use vector with the same success.

    • Thank. I just did not quite figure it out yet. Then I will make a vector. Can you tell me how to do such a search on a vector?) - Vladimir
    • @ Vladimir you do not care about performance at all? - pavel
    • absolutely. This is the home of the university. The main thing that worked) - Vladimir
    • @pavel: Give the person a first time to solve the problem at least :) Although lower_bound is of course the right solution, it makes sense to understand it and figure it out. - VladD 6:58 pm
    • 2
      @ Vladimir for (string name : Collection) if (!name.compare(0, find.length(), find)) cout << name; - pavel