Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Qt 4.8: Look for pairs into QHash/QMap<QString,int> using QRegExp

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

Scheduled Pinned Locked Moved General and Desktop
4 Posts 2 Posters 2.6k Views
  • 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 Offline
    T Offline
    teomurgi
    wrote on last edited by
    #1

    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
    0
    • raven-worxR Offline
      raven-worxR Offline
      raven-worx
      Moderators
      wrote on last edited by
      #2

      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
      0
      • T Offline
        T Offline
        teomurgi
        wrote on last edited by
        #3

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

        1 Reply Last reply
        0
        • raven-worxR Offline
          raven-worxR Offline
          raven-worx
          Moderators
          wrote on last edited by
          #4

          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
          0

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved