1/****************************************************************************
2**
3** Copyright (C) 2016 The Qt Company Ltd.
4** Contact: https://www.qt.io/licensing/
5**
6** This file is part of the test suite of the Qt Toolkit.
7**
8** $QT_BEGIN_LICENSE:GPL-EXCEPT$
9** Commercial License Usage
10** Licensees holding valid commercial Qt licenses may use this file in
11** accordance with the commercial license agreement provided with the
12** Software or, alternatively, in accordance with the terms contained in
13** a written agreement between you and The Qt Company. For licensing terms
14** and conditions see https://www.qt.io/terms-conditions. For further
15** information use the contact form at https://www.qt.io/contact-us.
16**
17** GNU General Public License Usage
18** Alternatively, this file may be used under the terms of the GNU
19** General Public License version 3 as published by the Free Software
20** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
21** included in the packaging of this file. Please review the following
22** information to ensure the GNU General Public License requirements will
23** be met: https://www.gnu.org/licenses/gpl-3.0.html.
24**
25** $QT_END_LICENSE$
26**
27****************************************************************************/
28#ifndef FUNCTIONS_H
29#define FUNCTIONS_H
30
31bool keepEvenIntegers(const int &x)
32{
33 return (x & 1) == 0;
34}
35
36class KeepEvenIntegers
37{
38public:
39 bool operator()(const int &x)
40 {
41 return (x & 1) == 0;
42 }
43};
44
45class Number
46{
47 int n;
48
49public:
50 Number()
51 : n(0)
52 { }
53
54 Number(int n)
55 : n(n)
56 { }
57
58 void multiplyBy2()
59 {
60 n *= 2;
61 }
62
63 Number multipliedBy2() const
64 {
65 return n * 2;
66 }
67
68 bool isEven() const
69 {
70 return (n & 1) == 0;
71 }
72
73 int toInt() const
74 {
75 return n;
76 }
77
78 QString toString() const
79 {
80 return QString::number(n);
81 }
82
83 bool operator==(const Number &other) const
84 {
85 return n == other.n;
86 }
87};
88
89void intSumReduce(int &sum, int x)
90{
91 sum += x;
92}
93
94class IntSumReduce
95{
96public:
97 void operator()(int &sum, int x)
98 {
99 sum += x;
100 }
101};
102
103void numberSumReduce(int &sum, const Number &x)
104{
105 sum += x.toInt();
106}
107
108class NumberSumReduce
109{
110public:
111 void operator()(int &sum, const Number &x)
112 {
113 sum += x.toInt();
114 }
115};
116
117#endif
118

source code of qtbase/tests/auto/concurrent/qtconcurrentmap/functions.h