Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Qt 4.8: Look for pairs into QHash/QMap<QString,int> using QRegExp

    General and Desktop
    2
    4
    2352
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • T
      teomurgi last edited by

      Hi all,

      I'm looking for a way to efficiently search for a set of pairs inside a hashmap of QString,int using regular expressions.
      In particular I want all the pairs which keys start with a particular string.

      Any ideas?

      Thank you

      1 Reply Last reply Reply Quote 0
      • raven-worx
        raven-worx Moderators last edited by

        Why do you want to do that?
        You want an "efficient" way for this, but also want to use QHash/QMap. But to solve what you want you have to iterate over all items anyway and check them. Thus you could accomplish the same thing with an ordinary QList/QVector/...

        But if you need to use a QHash you can use "QHash::keys()":http://qt-project.org/doc/qt-4.8/qhash.html#keys and iterate through all keys and do your regex on them.

        --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
        If you have a question please use the forum so others can benefit from the solution in the future

        1 Reply Last reply Reply Quote 0
        • T
          teomurgi last edited by

          Ok, so basically it cannot exist a way to do this in less than O(n)?

          1 Reply Last reply Reply Quote 0
          • raven-worx
            raven-worx Moderators last edited by

            no... since the hash is generated of the whole key.

            --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
            If you have a question please use the forum so others can benefit from the solution in the future

            1 Reply Last reply Reply Quote 0
            • First post
              Last post