Akonadi

vectorhelper.h
1 /*
2  SPDX-FileCopyrightText: 2015-2022 Laurent Montel <[email protected]>
3 
4  SPDX-License-Identifier: LGPL-2.0-or-later
5 */
6 
7 #pragma once
8 
9 #include <QSet>
10 #include <QVector>
11 
12 #include <algorithm>
13 
14 namespace Akonadi
15 {
16 template<typename Key, typename Value, template<typename, typename> class Container> QVector<Value> valuesToVector(const Container<Key, Value> &container)
17 {
19  values.reserve(container.size());
20  for (const auto &value : container) {
21  values.append(value);
22  }
23  return values;
24 }
25 
26 template<typename T> QSet<T> vectorToSet(const QVector<T> &container)
27 {
28  QSet<T> set;
29  set.reserve(container.size());
30  for (const auto &value : container) {
31  set.insert(value);
32  }
33  return set;
34 }
35 
36 template<typename Value, template<typename> class Container> QVector<Value> setToVector(const Container<Value> &container)
37 {
39  values.reserve(container.size());
40  for (const auto &value : container) {
41  values.append(value);
42  }
43  return values;
44 }
45 
46 } // namespace Akonadi
47 
void reserve(int size)
QSet::iterator insert(const T &value)
int size() const const
QVector< V > values(const QMultiHash< K, V > &c)
Helper integration between Akonadi and Qt.
This file is part of the KDE documentation.
Documentation copyright © 1996-2022 The KDE developers.
Generated on Thu Jun 30 2022 03:51:47 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.