58 #include <initializer_list>
61 #include <type_traits>
87 template <
class Key,
class T,
class Compare>
99 std::declval<Compare>()(std::declval<Key>(), std::declval<Key>()));
108 template<
class Key,
class T,
class Compare = std::less<Key>,
class KeyContainer = QList<Key>,
109 class MappedContainer = QList<T>>
112 static_assert(std::is_nothrow_destructible_v<T>,
"Types with throwing destructors are not supported in Qt containers.");
137 using size_type =
typename key_container_type::size_type;
164 return {
c->keys[i],
c->values[i] };
174 return c ==
o.c && i ==
o.i;
246 return {
c->keys[k],
c->values[k] };
301 return {
c->keys[i],
c->values[i] };
311 return c ==
o.c && i ==
o.i;
383 return {
c->keys[k],
c->values[k] };
407 const T &
value()
const {
return c->values[i]; }
416 template <
class,
class =
void>
417 struct is_marked_transparent_type : std::false_type { };
420 struct is_marked_transparent_type<
X,
std::void_t<typename X::is_transparent>> : std::true_type { };
423 using is_marked_transparent =
typename std::enable_if<
426 template <
typename It>
427 using is_compatible_iterator =
typename std::enable_if<
436 ensureOrderedUnique();
442 ensureOrderedUnique();
448 ensureOrderedUnique();
454 ensureOrderedUnique();
457 explicit QFlatMap(std::initializer_list<value_type> lst)
462 template <
class InputIt, is_compatible_iterator<InputIt> =
nullptr>
465 initWithRange(
first, last);
466 ensureOrderedUnique();
498 template <
class InputIt, is_compatible_iterator<InputIt> =
nullptr>
501 initWithRange(
first, last);
513 ensureOrderedUnique();
520 ensureOrderedUnique();
527 ensureOrderedUnique();
534 ensureOrderedUnique();
542 template <
class InputIt, is_compatible_iterator<InputIt> =
nullptr>
546 initWithRange(
first, last);
547 ensureOrderedUnique();
580 template <
class InputIt, is_compatible_iterator<InputIt> =
nullptr>
584 initWithRange(
first, last);
613 template <
class X,
class Y = Compare, is_marked_transparent<Y> =
nullptr>
621 c.values.erase(toValuesIterator(
it));
622 return fromKeysIterator(
c.keys.erase(toKeysIterator(
it)));
630 template <
class X,
class Y = Compare, is_marked_transparent<Y> =
nullptr>
641 template <
class X,
class Y = Compare, is_marked_transparent<Y> =
nullptr>
650 return it ==
end() ? defaultValue :
it.value();
653 template <
class X,
class Y = Compare, is_marked_transparent<Y> =
nullptr>
657 return it ==
end() ? defaultValue :
it.value();
663 return it ==
end() ?
T() :
it.value();
666 template <
class X,
class Y = Compare, is_marked_transparent<Y> =
nullptr>
670 return it ==
end() ?
T() :
it.value();
708 template <
typename...Args>
712 if (
it ==
end() || key_compare::operator()(
key,
it.key())) {
713 c.values.emplace(toValuesIterator(
it), std::forward<Args>(
args)...);
714 return { fromKeysIterator(
c.keys.insert(toKeysIterator(
it),
key)),
true };
720 template <
typename...Args>
724 if (
it ==
end() || key_compare::operator()(
key,
it.key())) {
725 c.values.emplace(toValuesIterator(
it), std::forward<Args>(
args)...);
726 return { fromKeysIterator(
c.keys.insert(toKeysIterator(
it), std::move(
key))),
true };
732 template <
typename M>
737 *toValuesIterator(
r.first) = std::forward<M>(
obj);
741 template <
typename M>
746 *toValuesIterator(
r.first) = std::forward<M>(
obj);
750 template <
class InputIt, is_compatible_iterator<InputIt> =
nullptr>
753 insertRange(
first, last);
760 insertRange(
first, last);
763 template <
class InputIt, is_compatible_iterator<InputIt> =
nullptr>
766 insertOrderedUniqueRange(
first, last);
773 insertOrderedUniqueRange(
first, last);
784 std::reverse_iterator<iterator>
rbegin() {
return std::reverse_iterator<iterator>(
end()); }
785 std::reverse_iterator<const_iterator>
rbegin()
const
787 return std::reverse_iterator<const_iterator>(
end());
790 std::reverse_iterator<iterator>
rend() {
791 return std::reverse_iterator<iterator>(
begin());
793 std::reverse_iterator<const_iterator>
rend()
const
795 return std::reverse_iterator<const_iterator>(
begin());
797 std::reverse_iterator<const_iterator>
crend()
const {
return rend(); }
801 auto cit = std::as_const(*this).lower_bound(
key);
802 return { &
c, cit.i };
805 template <
class X,
class Y = Compare, is_marked_transparent<Y> =
nullptr>
808 auto cit = std::as_const(*this).lower_bound(
key);
809 return { &
c, cit.i };
814 return fromKeysIterator(std::lower_bound(
c.keys.begin(),
c.keys.end(),
key,
key_comp()));
817 template <
class X,
class Y = Compare, is_marked_transparent<Y> =
nullptr>
820 return fromKeysIterator(std::lower_bound(
c.keys.begin(),
c.keys.end(),
key,
key_comp()));
825 return { &
c, std::as_const(*this).find(
key).i };
828 template <
class X,
class Y = Compare, is_marked_transparent<Y> =
nullptr>
831 return { &
c, std::as_const(*this).find(
key).i };
838 if (!key_compare::operator()(
key,
it.key()))
845 template <
class X,
class Y = Compare, is_marked_transparent<Y> =
nullptr>
850 if (!key_compare::operator()(
key,
it.key()))
887 template <
class InputIt, is_compatible_iterator<InputIt> =
nullptr>
888 void initWithRange(InputIt
first, InputIt last)
891 while (
first != last) {
892 c.keys.push_back(
first->first);
893 c.values.push_back(
first->second);
910 return c.keys.begin() +
it.i;
915 return c.values.begin() +
it.i;
918 template <
class InputIt>
919 void insertRange(InputIt
first, InputIt last)
923 c.values.resize(
c.keys.size());
928 ensureOrderedUnique();
931 class IndexedKeyComparator
934 IndexedKeyComparator(
const QFlatMap *am)
941 return m->key_comp()(
m->c.keys[
i],
m->c.keys[k]);
948 template <
class InputIt>
949 void insertOrderedUniqueRange(InputIt
first, InputIt last)
953 c.values.resize(
c.keys.size());
959 std::vector<size_type>
p(
size_t(
c.keys.size()));
960 std::iota(
p.begin(),
p.end(), 0);
961 std::inplace_merge(
p.begin(),
p.begin() +
s,
p.end(), IndexedKeyComparator(
this));
966 void ensureOrderedUnique()
968 std::vector<size_type>
p(
size_t(
c.keys.size()));
969 std::iota(
p.begin(),
p.end(), 0);
970 std::stable_sort(
p.begin(),
p.end(), IndexedKeyComparator(
this));
975 void applyPermutation(
const std::vector<size_type> &
p)
978 std::vector<bool>
done(
s);
997 if (
c.keys.size() < 2)
1002 if (key_compare::operator()(*
i, *k) || key_compare::operator()(*k, *
i)) {
1009 i =
c.keys.erase(
i);
1020 template<
class Key,
class T, qsizetype N = 256,
class Compare = std::less<Key>>
small capitals from c petite p scientific i
[1]
mock_pointer< reference > pointer
const_iterator & operator+=(size_type n)
bool operator>=(const const_iterator &other) const
friend const_iterator operator+(size_type n, const const_iterator a)
const_iterator(const containers *ac, size_type ai)
const_iterator operator++(int)
bool operator>(const const_iterator &other) const
friend difference_type operator-(const const_iterator b, const const_iterator a)
const_iterator(iterator o)
std::random_access_iterator_tag iterator_category
const_iterator & operator++()
reference operator*() const
const_iterator & operator-=(size_type n)
bool operator==(const const_iterator &o) const
reference operator[](size_type n) const
pointer operator->() const
bool operator<(const const_iterator &other) const
ptrdiff_t difference_type
bool operator<=(const const_iterator &other) const
bool operator!=(const const_iterator &o) const
std::pair< const Key, const T > value_type
friend const_iterator operator-(const const_iterator a, size_type n)
std::pair< const Key &, const T & > reference
friend const_iterator operator+(const const_iterator a, size_type n)
const_iterator & operator--()
const_iterator operator--(int)
iterator(containers *ac, size_type ai)
bool operator>(const iterator &other) const
iterator & operator-=(size_type n)
reference operator[](size_type n) const
iterator & operator+=(size_type n)
std::random_access_iterator_tag iterator_category
friend iterator operator-(const iterator a, size_type n)
friend iterator operator+(size_type n, const iterator a)
pointer operator->() const
bool operator==(const iterator &o) const
reference operator*() const
bool operator>=(const iterator &other) const
bool operator<(const iterator &other) const
std::pair< const Key &, T & > reference
bool operator<=(const iterator &other) const
ptrdiff_t difference_type
bool operator!=(const iterator &o) const
mock_pointer< reference > pointer
friend iterator operator+(const iterator a, size_type n)
std::pair< const Key, T > value_type
friend difference_type operator-(const iterator b, const iterator a)
std::reverse_iterator< const_iterator > crbegin() const
std::reverse_iterator< const_iterator > rend() const
std::pair< iterator, bool > insert_or_assign(Key &&key, M &&obj)
bool isEmpty() const noexcept
bool empty() const noexcept
std::reverse_iterator< iterator > rend()
QFlatMap(Qt::OrderedUniqueRange_t, const key_container_type &keys, const mapped_container_type &values, const Compare &compare)
QFlatMap(Qt::OrderedUniqueRange_t, InputIt first, InputIt last)
std::reverse_iterator< const_iterator > rbegin() const
QFlatMap(const key_container_type &keys, mapped_container_type &&values, const Compare &compare)
size_type count() const noexcept
QFlatMap(key_container_type &&keys, mapped_container_type &&values)
T & operator[](Key &&key)
T value(const Key &key) const
const_iterator lower_bound(const X &key) const
std::pair< iterator, bool > insert_or_assign(const Key &key, M &&obj)
const_iterator begin() const
const mapped_container_type & values() const noexcept
std::reverse_iterator< const_iterator > crend() const
const_iterator lower_bound(const Key &key) const
void insert(Qt::OrderedUniqueRange_t, const value_type *first, const value_type *last)
QFlatMap(Qt::OrderedUniqueRange_t, key_container_type &&keys, const mapped_container_type &values, const Compare &compare)
QFlatMap(const Compare &compare)
std::pair< iterator, bool > try_emplace(Key &&key, Args &&...args)
std::reverse_iterator< iterator > rbegin()
key_compare key_comp() const noexcept
iterator find(const X &key)
bool contains(const X &key) const
bool contains(const Key &key) const
const_iterator find(const Key &key) const
T value(const X &key) const
void insert(Qt::OrderedUniqueRange_t, InputIt first, InputIt last)
iterator erase(iterator it)
const_iterator cbegin() const
iterator lower_bound(const Key &key)
const key_container_type & keys() const noexcept
typename key_container_type::size_type size_type
QFlatMap(key_container_type &&keys, const mapped_container_type &values)
T value(const X &key, const T &defaultValue) const
QFlatMap(key_container_type &&keys, const mapped_container_type &values, const Compare &compare)
QFlatMap(Qt::OrderedUniqueRange_t, key_container_type &&keys, mapped_container_type &&values)
const_iterator constBegin() const
iterator find(const Key &key)
QFlatMap(Qt::OrderedUniqueRange_t, std::initializer_list< value_type > lst, const Compare &compare)
std::pair< iterator, bool > insert(Key &&key, const T &value)
bool remove(const Key &key)
const_iterator cend() const
QFlatMap(key_container_type &&keys, mapped_container_type &&values, const Compare &compare)
T & operator[](const Key &key)
const_iterator constEnd() const
QFlatMap(Qt::OrderedUniqueRange_t, const key_container_type &keys, mapped_container_type &&values, const Compare &compare)
void insert(const value_type *first, const value_type *last)
typename value_compare::value_type value_type
QFlatMap(Qt::OrderedUniqueRange_t, std::initializer_list< value_type > lst)
QFlatMap(InputIt first, InputIt last)
const_iterator find(const X &key) const
void reserve(size_type s)
std::pair< iterator, bool > insert(const Key &key, T &&value)
std::pair< iterator, bool > try_emplace(const Key &key, Args &&...args)
QFlatMap(const key_container_type &keys, mapped_container_type &&values)
std::pair< iterator, bool > insert(Key &&key, T &&value)
QFlatMap(Qt::OrderedUniqueRange_t, const key_container_type &keys, mapped_container_type &&values)
iterator lower_bound(const X &key)
KeyContainer key_container_type
QFlatMap(Qt::OrderedUniqueRange_t, key_container_type &&keys, const mapped_container_type &values)
MappedContainer mapped_container_type
QFlatMap(InputIt first, InputIt last, const Compare &compare)
T value(const Key &key, const T &defaultValue) const
bool remove(const X &key)
QFlatMap(const key_container_type &keys, const mapped_container_type &values)
const_iterator end() const
void insert(InputIt first, InputIt last)
QFlatMap(const key_container_type &keys, const mapped_container_type &values, const Compare &compare)
value_compare value_comp() const noexcept
size_type size() const noexcept
size_type capacity() const noexcept
T operator[](const Key &key) const
QFlatMap(std::initializer_list< value_type > lst, const Compare &compare)
QFlatMap(Qt::OrderedUniqueRange_t, const key_container_type &keys, const mapped_container_type &values)
QFlatMap(Qt::OrderedUniqueRange_t, key_container_type &&keys, mapped_container_type &&values, const Compare &compare)
std::pair< iterator, bool > insert(const Key &key, const T &value)
QFlatMap(std::initializer_list< value_type > lst)
QFlatMap(Qt::OrderedUniqueRange_t, InputIt first, InputIt last, const Compare &compare)
bool operator()(const value_type &lhs, const value_type &rhs) const noexcept(is_comparator_noexcept)
std::pair< const Key, T > value_type
QFlatMapValueCompare()=default
static constexpr bool is_comparator_noexcept
QFlatMapValueCompare(const Compare &key_compare)
constexpr T & operator()(T &v) const
auto it unsigned count const
typename C::value_type value_type
typename C::const_iterator const_iterator
typename C::iterator iterator
constexpr OrderedUniqueRange_t OrderedUniqueRange
void reserveIfForwardIterator(Container *, InputIterator, InputIterator)
int distance(TestIterator &a, TestIterator &b)
EGLOutputLayerEXT EGLint EGLAttrib value
QT_BEGIN_NAMESPACE bool done
GLenum GLsizei GLsizei GLint * values
[16]
GLboolean GLboolean GLboolean b
GLboolean GLboolean GLboolean GLboolean a
[7]
QtPrivate::QRegularExpressionMatchIteratorRangeBasedForIterator begin(const QRegularExpressionMatchIterator &iterator)
mapped_container_type values
void compare(Input input, FnUnderTest fn_under_test, const QByteArray &output)
virtual HRESULT STDMETHODCALLTYPE Compare(__RPC__in_opt ITextRangeProvider *range, __RPC__out BOOL *pRetVal)=0