Reputation: 351
I want to maintain a list of Names
and then search if the literal "a name"
exists in the list.
Should I use a QMap:
QMap<QString, bool> Names;
Names.find("a name");
Or a QList:
QList<QString> Names:
bool found = false;
foreach(QString name, Names){
if (name == "a name"){
found = true;
break;
}
}
Upvotes: 0
Views: 467
Reputation: 2293
What you may want to use is QSet
You can search whether a name
is in the Names
by calling contains() method
Upvotes: 2
Reputation: 22826
If you don't need the container to have any order, use a QSet<QString>
.
Upvotes: 3