Lumiera  0.pre.03
»edit your freedom«
test-coll.hpp
Go to the documentation of this file.
1 /*
2  TEST-COLL.hpp - containers and collections with test data
3 
4  Copyright (C) Lumiera.org
5  2010, Hermann Vosseler <Ichthyostega@web.de>
6 
7  This program is free software; you can redistribute it and/or
8  modify it under the terms of the GNU General Public License as
9  published by the Free Software Foundation; either version 2 of
10  the License, or (at your option) any later version.
11 
12  This program is distributed in the hope that it will be useful,
13  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  GNU General Public License for more details.
16 
17  You should have received a copy of the GNU General Public License
18  along with this program; if not, write to the Free Software
19  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 
21 */
22 
23 
29 #ifndef LIB_TEST_TEST_COLL_H
30 #define LIB_TEST_TEST_COLL_H
31 
32 
33 #include <unordered_map>
34 #include <iostream>
35 #include <vector>
36 #include <map>
37 
38 
39 namespace lib {
40 namespace test{
41 
42 
43  typedef std::vector<int> VecI;
44 
45  template<class VEC>
46  inline VEC
47  getTestSeq_int(const uint NUM_ELMS)
48  {
49  VEC vec;
50  for (uint i=0; i<NUM_ELMS; ++i)
51  vec.push_back (i);
52 
53  return vec;
54  }
55 
56 
57  typedef std::map<int,int> MapII;
58  typedef std::multimap<int,int> MMapII;
59 
60  typedef std::unordered_map<int,int> HMapII;
61  typedef std::unordered_multimap<int,int> HMMapII;
62 
63 
64  template<class MAP>
65  inline MAP
66  getTestMap_int(const uint NUM_ELMS)
67  {
68  MAP map;
69  for (uint i=0; i<NUM_ELMS; ++i)
70  map[i] = 2*i;
71 
72  return map;
73  }
74 
75  template<class MUMAP>
76  inline MUMAP
77  getTestMultiMap_int(const uint NUM_ELMS)
78  {
79  MUMAP map;
80  for (uint i=0; i<NUM_ELMS; ++i)
81  for (uint j=NUM_ELMS-i; j; --j)
82  map.insert (std::make_pair (i, j));
83 
84  return map;
85  }
86 
87 
88 
89  template<class ITER>
90  inline void
91  pullOut (ITER const& i)
92  {
93  for (ITER ii(i); ii ; ++ii )
94  std::cout << "::" << *ii;
95  }
96 
97 
98 
99 }} // namespace lib::test
100 #endif /*LIB_TEST_TEST_COLL_H*/
Definition: run.hpp:49
Implementation namespace for support and library code.