Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-22026

Bug of QSet

    XMLWordPrintable

Details

    • 4f2c96eaa8bfa4d8a6dfb92096e4e4030d0cdea7

    Description

      #include <QSet>
      #include <QTime>
      #include <QDebug>
      
      int main() {
          int length1 = 1000000;
          int length2 = 1000;
      
          QSet<int> set1;
          for (int i = 0; i < length1; ++i) {
              set1.insert(qrand());
          }
      
          QSet<int> set2;
          for (int i = 0; i < length2; ++i) {
              set2.insert(qrand());
          }
      
          qDebug() << set1.size() << set2.size();
      
          QTime time;
          QSet<int> intersect = set1;
          time.start();
          intersect.intersect(set2);
          qDebug() << time.elapsed() << intersect.size();
      
      
          intersect = set2;
          time.restart();
          intersect.intersect(set1);
          qDebug() << time.elapsed() << intersect.size();
      }
      

      Output:

      1000000 1000
      445 0
      1 0

      But intersect must be independ of permutation sets.

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            mitch_curtis Mitch Curtis
            mishex Sergey Mishin
            Votes:
            1 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes