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. Which container is good for below scenario mentioned.

Which container is good for below scenario mentioned.

Scheduled Pinned Locked Moved Solved General and Desktop
5 Posts 3 Posters 355 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.
  • A Offline
    A Offline
    Ayush Gupta
    wrote on last edited by
    #1

    I have scenario where I need to store some data where I can have

    count as unique number
    and each count should be associated with some data and its value

    I was thinking to use map<int, map<string,string>> but since only one data and value will be associated with count will it be overkill to use map<string,string> ?

    Kindly suggest

    JonBJ 1 Reply Last reply
    0
    • VRoninV Offline
      VRoninV Offline
      VRonin
      wrote on last edited by VRonin
      #5

      map<int, tuple<string, string/*, string, ... */> >

      Where

      • map can be a std::map, std::unordered_map, QMap, QHash or any key-value container and
      • tuple is std::pair, QPair or std::tuple or even just a custom struct

      "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
      ~Napoleon Bonaparte

      On a crusade to banish setIndexWidget() from the holy land of Qt

      1 Reply Last reply
      4
      • A Ayush Gupta

        I have scenario where I need to store some data where I can have

        count as unique number
        and each count should be associated with some data and its value

        I was thinking to use map<int, map<string,string>> but since only one data and value will be associated with count will it be overkill to use map<string,string> ?

        Kindly suggest

        JonBJ Offline
        JonBJ Offline
        JonB
        wrote on last edited by
        #2

        @Ayush-Gupta
        Do you want to use std:: containers or Qt containers?

        1 Reply Last reply
        2
        • A Offline
          A Offline
          Ayush Gupta
          wrote on last edited by
          #3

          Qt containers would be good for me

          JonBJ 1 Reply Last reply
          0
          • A Ayush Gupta

            Qt containers would be good for me

            JonBJ Offline
            JonBJ Offline
            JonB
            wrote on last edited by
            #4

            @Ayush-Gupta
            Then you will want either QMap or QHash, as discussed in https://doc.qt.io/qt-5/qmap.html#details according to your requirements.

            1 Reply Last reply
            1
            • VRoninV Offline
              VRoninV Offline
              VRonin
              wrote on last edited by VRonin
              #5

              map<int, tuple<string, string/*, string, ... */> >

              Where

              • map can be a std::map, std::unordered_map, QMap, QHash or any key-value container and
              • tuple is std::pair, QPair or std::tuple or even just a custom struct

              "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
              ~Napoleon Bonaparte

              On a crusade to banish setIndexWidget() from the holy land of Qt

              1 Reply Last reply
              4

              • Login

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