1// Copyright (C) 2020 Klaralvdalens Datakonsult AB (KDAB).
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#ifndef QT3DCORE_VECTOR_HELPER_P_H
5#define QT3DCORE_VECTOR_HELPER_P_H
6
7//
8// W A R N I N G
9// -------------
10//
11// This file is not part of the Qt API. It exists for the convenience
12// of other Qt classes. This header file may change from version to
13// version without notice, or even be removed.
14//
15// We mean it.
16//
17
18#include <Qt3DCore/private/qt3dcore-config_p.h>
19#include <qobjectdefs.h>
20#include <vector>
21#include <algorithm>
22
23QT_BEGIN_NAMESPACE
24
25namespace Qt3DCore {
26
27template<typename T, typename U>
28inline void moveAtEnd(std::vector<T>& destination, std::vector<U>&& source)
29{
30 destination.insert(destination.end(),
31 std::make_move_iterator(source.begin()),
32 std::make_move_iterator(source.end()));
33}
34
35template<typename T>
36inline T moveAndClear(T &data)
37{
38 T ret(std::move(data));
39 data.clear();
40 return ret;
41}
42
43template<typename T, typename U>
44inline void append(std::vector<T>& destination, const U& source)
45{
46 destination.insert(destination.end(),
47 source.cbegin(),
48 source.cend());
49}
50
51template<typename T, typename U>
52inline bool contains(const std::vector<T>& destination, const U& element) noexcept
53{
54 return std::find(destination.begin(), destination.end(), element) != destination.end();
55}
56
57template <typename ForwardIterator>
58inline void deleteAll(ForwardIterator begin, ForwardIterator end)
59{
60 while (begin != end) {
61 delete *begin;
62 ++begin;
63 }
64}
65
66template <typename Container>
67inline void deleteAll(const Container &c)
68{
69 qDeleteAll(c.begin(), c.end());
70}
71
72} // namespace Qt3DCore
73
74QT_END_NAMESPACE
75#endif // QT3DCORE_VECTOR_HELPER_P_H
76

source code of qt3d/src/core/vector_helper_p.h