libStatGen Software 1
InplaceMerge.cpp
1/*
2 * Copyright (C) 2010 Regents of the University of Michigan
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18#include "InplaceMerge.h"
19
20#if defined(TEST)
21#include "iostream"
22#include "Generic.h"
23
24int main(int argc, const char **argv)
25{
26 int a[] = {1,2,3,4,5};
27 int b[] = {2,4,6,7,10};
28 int c[] = {3,5,8,10,11};
29
30 std::vector<int> z(15);
31
32 std::copy(a, a+5, z.begin());
33 std::copy(b, b+5, z.begin() + 5);
34 std::copy(c, c+5, z.begin() + 10);
35
36 std::vector<int> indeces, counts;
37
38 indeces.push_back(0);
39 indeces.push_back(5);
40 indeces.push_back(10);
41
42 counts.push_back(5);
43 counts.push_back(5);
44 counts.push_back(5);
45
46 inplace_merge(indeces, counts, 0, 3, z);
47
48 std::cout << z;
49}
50
51#endif