Details
-
Task
-
Resolution: Unresolved
-
P3: Somewhat important
-
None
-
None
-
2
-
Foundation Sprint 120
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:
- 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);
- 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().
- the BannedHeaders array in qnetworkreplywasmimpl.cpp is ported to QSortedOffsetStringArray and its contains() method.
Attachments
Issue Links
- relates to
-
QTBUG-103721 Use q20::is_sorted to statically assert that static arrays are sorted
- Reported
Gerrit Reviews
For Gerrit Dashboard: QTBUG-109233 | ||||||
---|---|---|---|---|---|---|
# | Subject | Branch | Project | Status | CR | V |
580769,1 | QOffsetStringArray: add iterators | dev | qt/qtbase | Status: NEW | 0 | 0 |