container to store unique strings



  • i need to store unique strings in a container. i know i can use qset. however, inserts and finds will be frequent. so i'd like to store them in something like a hash. but i only have strings (i.e. keys) and not values. what should i use?



  • How about QStringList? It's a type declaration to QList<QString>.
    Depending on your actual needs you can also use QVector<QString>. Either documentation lists advantages/disadvantages over the other one.



  • @user4592357 said in container to store unique strings:

    i need to store unique strings in a container. i know i can use qset. however, inserts and finds will be frequent. so i'd like to store them in something like a hash. but i only have strings (i.e. keys) and not values. what should i use?

    Quoting http://doc.qt.io/qt-5/qset.html :

    QSet<T> is one of Qt's generic container classes. It stores values in an unspecified order and provides very fast lookup of the values. Internally, QSet<T> is implemented as a QHash.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.