• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //----------------------------------------------------------------------------
2 /// @file int_array.hpp
3 /// @brief This file contains the struct int_array , which is an array of
4 ///        uint64_t elements, being the template parameter NN the number of
5 ///        elements in the array
6 ///
7 /// @author Copyright (c) 2010 2015 Francisco José Tapia (fjtapia@gmail.com )\n
8 ///         Distributed under the Boost Software License, Version 1.0.\n
9 ///         ( See accompanyingfile LICENSE_1_0.txt or copy at
10 ///           http://www.boost.org/LICENSE_1_0.txt  )
11 /// @version 0.1
12 ///
13 /// @remarks
14 //-----------------------------------------------------------------------------
15 #ifndef __BOOST_SORT_COMMON_INT_ARRAY_HPP
16 #define __BOOST_SORT_COMMON_INT_ARRAY_HPP
17 
18 #include <cstdint>
19 #include <iostream>
20 
21 namespace boost
22 {
23 namespace sort
24 {
25 namespace common
26 {
27 
28 template<uint32_t NN>
29 struct int_array
30 {
31     uint64_t M[NN];
32 
33     template<class generator>
generateboost::sort::common::int_array34     static int_array<NN> generate(generator & gen)
35     {
36         int_array<NN> result;
37         for (uint32_t i = 0; i < NN; ++i)
38         {
39             result.M[i] = gen();
40         };
41         return result;
42     };
43 
counterboost::sort::common::int_array44     uint64_t counter(void) const
45     {
46         uint64_t Acc = M[0];
47         for (uint32_t i = 1; i < NN; Acc += M[i++])
48             ;
49         return Acc;
50     };
51 };
52 
53 template<class IA>
54 struct H_comp
55 {
operator ( )boost::sort::common::H_comp56     bool operator ( )(const IA & A1, const IA & A2) const
57     {
58         return (A1.counter() < A2.counter());
59     };
60 };
61 
62 template<class IA>
63 struct L_comp
64 {
operator ( )boost::sort::common::L_comp65     bool operator ( )(const IA & A1, const IA & A2) const
66     {
67         return (A1.M[0] < A2.M[0]);
68     };
69 };
70 //***************************************************************************
71 };//    End namespace benchmark
72 };//    End namespace sort
73 };//    End namespace boost
74 //***************************************************************************
75 #endif // end of int_array.hpp
76