Reputation: 843
Trying to make a simple program to catalogue books. Something like this, for example:
struct book{
string author;
string title;
int catalogNumber;
}
Ultimately, I want to be able to do title searches based on a range OR author searches based on a range. So the user could specify to display results of books where the title begins with "aa" though "be"...or authors in the same range.
I was going to keep maintain two sets...one for author searches and the other for title searches. However, I realized that when I load the library from a csv file into the sets, I don't think it'll allow me to put two books of the same title into the set for the title search set...or books with the same author for the author search set.
Is this correct? Is there another data structure that could do this easily?
Thanks!
Upvotes: 2
Views: 313
Reputation: 70929
Sure - use multiset or multimap. They are quite the same simply allow duplicate keys.
Upvotes: 2