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

qOffsetStringArray(): allow iteration

    XMLWordPrintable

Details

    Description

      QOffsetStringArray is a kind of container, and it's sometimes useful to iterate over it (esp. with std::lower_bound). The value_type if the iterator should be decltype(viewAt(0)).

      Acceptance criteria:

      1. The following tests pass:
        constexpr auto table = qOffsetStringArray("aha", "boo", "coocoo");
        static_assert(q20::is_sorted(table.begin(), table.end()));
        auto it = std::lower_bound(table.begin(), table.end(), table.viewAt(1));
        assert(it == table.begin() + 1);
        auto rit = std::lower_bound(table.rbegin(), table.rend(), QByteArrayView{"axe"}, std::greater<>{});
        assert(rit == table.rbegin() + 2);
        
      2. there is a QSortedOffsetStringArray that statically asserts that the elements are ordered and provides a member contains() with O(log N) complexity (ie. binary search, using std::lower_bound().
      3. the BannedHeaders array in qnetworkreplywasmimpl.cpp is ported to QSortedOffsetStringArray and its contains() method.

      Attachments

        Issue Links

          For Gerrit Dashboard: QTBUG-109233
          # Subject Branch Project Status CR V

          Activity

            People

              mmutz Marc Mutz
              mmutz Marc Mutz
              Vladimir Minenko Vladimir Minenko
              Alex Blasche Alex Blasche
              Votes:
              1 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:

                Gerrit Reviews

                  There is 1 open Gerrit change