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. QList<double> memory model ?
Qt 6.11 is out! See what's new in the release blog

QList<double> memory model ?

Scheduled Pinned Locked Moved Unsolved General and Desktop
5 Posts 3 Posters 1.5k Views 3 Watching
  • 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.
  • Andy314A Offline
    Andy314A Offline
    Andy314
    wrote on last edited by Andy314
    #1

    Hello,
    I have read in the documentation that for all types smaller or equal than a pointer a QList stores the values directly and not with pointers.
    That means for a 32-bit compiler, doubles will be stored with pointer. Is this correct?

    If yes, how can I avoid it, because for doubles this an enormous overhead and makes no sense.
    (Besides standard C-math-vector-functions will not run.)

    1 Reply Last reply
    0
    • Chris KawaC Offline
      Chris KawaC Offline
      Chris Kawa
      Lifetime Qt Champion
      wrote on last edited by
      #2

      That's correct. QList is not the best container if you care about contiguous memory layout. QVector is far better for that.
      If you want a list anyway then either switch to 64bit (which we all should've done long ago IMHO) or don't use QList (maybe a std::list instead?).

      Andy314A 1 Reply Last reply
      0
      • SGaistS Offline
        SGaistS Offline
        SGaist
        Lifetime Qt Champion
        wrote on last edited by
        #3

        Hi,

        To add to Chris, here you can find a very good analysis of Qt's and their STL's counterparts containers.

        Interested in AI ? www.idiap.ch
        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

        Andy314A 1 Reply Last reply
        0
        • Chris KawaC Chris Kawa

          That's correct. QList is not the best container if you care about contiguous memory layout. QVector is far better for that.
          If you want a list anyway then either switch to 64bit (which we all should've done long ago IMHO) or don't use QList (maybe a std::list instead?).

          Andy314A Offline
          Andy314A Offline
          Andy314
          wrote on last edited by
          #4

          Hi @Chris-Kawa
          That is a pity. 64 bit is no way for me. I have subclassed the QList to integrate some useful additional functions, therefore I must do the same for QVector. I must think about it, maybe there is a way to write this code only once with templates.
          I there really not trick to force the QList to use contiguous layout for doubles ?

          1 Reply Last reply
          0
          • SGaistS SGaist

            Hi,

            To add to Chris, here you can find a very good analysis of Qt's and their STL's counterparts containers.

            Andy314A Offline
            Andy314A Offline
            Andy314
            wrote on last edited by
            #5

            Hi @SGaist,
            thank for the tip, I will read it tomorrow.

            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