Debian Codegraph @

src/internal/containers.h

raw symbols ◀ ▶ SCIP
1 Debian patch touch this file
1 /*
2 * %injeqt copyright begin%
3 * Copyright 2014 Rafał Malinowski ([email protected])
4 * %injeqt copyright end%
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
10 *
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 */
20
21 #pragma once
22
23 #include "internal.h"cxx . . $ `<file>/src/internal/internal.h`/
24
25 #include <algorithm>
•26 #include <functional>
27 #include <vector>
28
29 /**
30 * @file
31 * @brief Helper functions for containers.
32 */
33
34 namespace injeqtcxx . . $ injeqt/ { namespace internalcxx . . $ injeqt/internal/ {
35
36 /**
37 * @brief Functional interface to std::transform.
38 * @tparam S type of source items
39 * @tparam T type of result items
40 * @param source source data
41 * @param f transforming function
42 */
43 template<typename S, typename T>
44 inline stdcxx . . $ std/::vectorcxx . . $ std/vector#<T> transformcxx . . $ injeqt/internal/transform(a6e4e1289b9119f6).(const stdcxx . . $ std/::vectorcxx . . $ std/vector#<S> &source, stdcxx . . $ std/::functioncxx . . $ std/function#<T(S)> f)
45 {
46 auto result = stdcxx . . $ std/::vectorcxx . . $ std/vector#<T>{};
47 stdcxx . . $ std/::transformcxx . . $ std/transform(da30451c4a040264).(stdcxx . . $ std/::begincxx . . $ std/begin(8c94f1ffb8cd32fc).(source), stdcxx . . $ std/::endcxx . . $ std/end(c459d8867450f8b2).(source), stdcxx . . $ std/::back_insertercxx . . $ std/back_inserter(7b559d6bdd90ff74).(result), f);
48 return result;
49 }
50
51 /**
52 * @brief Extract data from multiple vectors into one vector.
53 * @tparam S type of source items
54 * @tparam T type of result items
55 * @param f function returning vector for each item in source
56 */
57 template<typename S, typename T>
58 inline stdcxx . . $ std/::vectorcxx . . $ std/vector#<T> extractcxx . . $ injeqt/internal/extract(cfc480f9714e74a1).(const stdcxx . . $ std/::vectorcxx . . $ std/vector#<S> &sources, stdcxx . . $ std/::functioncxx . . $ std/function#<stdcxx . . $ std/::vectorcxx . . $ std/vector#<T>(const S &)> f)
59 {
60 auto result = stdcxx . . $ std/::vectorcxx . . $ std/vector#<T>{};
61 for (auto &&source : sources)
62 {
63 auto v = f(source);
64 stdcxx . . $ std/::copycxx . . $ std/copy(88304b602929f6f4).(stdcxx . . $ std/::begincxx . . $ std/begin(a139f8bc8514c5ac).(v), stdcxx . . $ std/::endcxx . . $ std/end(c459d8867450f8b2).(v), stdcxx . . $ std/::back_insertercxx . . $ std/back_inserter(7b559d6bdd90ff74).(result));
65 }
66 return result;
67 }
68
69 }}