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. Can't understand return type of qBinaryFind();
Forum Updated to NodeBB v4.3 + New Features

Can't understand return type of qBinaryFind();

Scheduled Pinned Locked Moved Solved General and Desktop
8 Posts 4 Posters 943 Views 2 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.
  • E Offline
    E Offline
    Engelard
    wrote on 9 Nov 2018, 17:07 last edited by Engelard 11 Sept 2018, 17:08
    #1

    I read all documentation which concerning this function(all 3 variations), and still can't get why developers did'nt make as return type just vector of ints... I tried as at example, and it gives an error:

    0_1541783243991_qfind.jpg

    P.S. tried to set return value to *uchar as compiler asks, it always return 253 in any case. Confused.

    1 Reply Last reply
    0
    • M Offline
      M Offline
      mranger90
      wrote on 9 Nov 2018, 18:06 last edited by
      #2

      I'm guessing that tempByte is a QVector<uchar>. if that is the case then the iterator must be of type QVector<uchar>, not QVector<int>

      E 1 Reply Last reply 12 Nov 2018, 12:57
      7
      • S Offline
        S Offline
        SGaist
        Lifetime Qt Champion
        wrote on 9 Nov 2018, 20:53 last edited by
        #3

        Hi,

        In addition to @mranger90, as suggested in the current documentation, you should use std::binary_search or std::lower_bound instead.

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

        1 Reply Last reply
        2
        • M mranger90
          9 Nov 2018, 18:06

          I'm guessing that tempByte is a QVector<uchar>. if that is the case then the iterator must be of type QVector<uchar>, not QVector<int>

          E Offline
          E Offline
          Engelard
          wrote on 12 Nov 2018, 12:57 last edited by Engelard 11 Dec 2018, 13:09
          #4

          @mranger90 Thanks! Did'nt notice such a small mistake.

          @SGaist oh.. but why they went obsolete? What's wrong with those functions?

          P.S. still can't understand the point of iterator type, why dont use simple int instead?

          J 1 Reply Last reply 12 Nov 2018, 14:18
          0
          • E Engelard
            12 Nov 2018, 12:57

            @mranger90 Thanks! Did'nt notice such a small mistake.

            @SGaist oh.. but why they went obsolete? What's wrong with those functions?

            P.S. still can't understand the point of iterator type, why dont use simple int instead?

            J Offline
            J Offline
            jsulm
            Lifetime Qt Champion
            wrote on 12 Nov 2018, 14:18 last edited by
            #5

            @Engelard said in Can't understand return type of qBinaryFind();:

            P.S. still can't understand the point of iterator type, why dont use simple int instead?

            Because you can use the iterator as parameter to any other function which expects an iterator.

            I guess these functions are deprecated because the standard C++ library now provides same functionality.

            https://forum.qt.io/topic/113070/qt-code-of-conduct

            1 Reply Last reply
            3
            • S Offline
              S Offline
              SGaist
              Lifetime Qt Champion
              wrote on 12 Nov 2018, 20:46 last edited by
              #6

              @jsulm's guess is correct. The goal of Qt is not to duplicate the STD. Since the original functions provided by Qt have been integrated in the STD, there's no reason to keep them hence they are now considered obsolete.

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

              E 1 Reply Last reply 12 Nov 2018, 22:16
              0
              • S SGaist
                12 Nov 2018, 20:46

                @jsulm's guess is correct. The goal of Qt is not to duplicate the STD. Since the original functions provided by Qt have been integrated in the STD, there's no reason to keep them hence they are now considered obsolete.

                E Offline
                E Offline
                Engelard
                wrote on 12 Nov 2018, 22:16 last edited by
                #7

                @SGaist why then exists stuff like QVectors? they are also the same.

                1 Reply Last reply
                0
                • S Offline
                  S Offline
                  SGaist
                  Lifetime Qt Champion
                  wrote on 12 Nov 2018, 22:22 last edited by SGaist 11 Dec 2018, 22:22
                  #8

                  No they are not, Qt's containers are implicitly shared which is not the case of the STD containers.

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

                  1 Reply Last reply
                  1

                  6/8

                  12 Nov 2018, 20:46

                  • Login

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