Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:51:46

0001 //----------------------------------------------------------------------------
0002 /// @file int_array.hpp
0003 /// @brief This file contains the struct int_array , which is an array of
0004 ///        uint64_t elements, being the template parameter NN the number of
0005 ///        elements in the array
0006 ///
0007 /// @author Copyright (c) 2010 2015 Francisco José Tapia (fjtapia@gmail.com )\n
0008 ///         Distributed under the Boost Software License, Version 1.0.\n
0009 ///         ( See accompanyingfile LICENSE_1_0.txt or copy at
0010 ///           http://www.boost.org/LICENSE_1_0.txt  )
0011 /// @version 0.1
0012 ///
0013 /// @remarks
0014 //-----------------------------------------------------------------------------
0015 #ifndef __BOOST_SORT_COMMON_INT_ARRAY_HPP
0016 #define __BOOST_SORT_COMMON_INT_ARRAY_HPP
0017 
0018 #include <ciso646>
0019 #include <cstdint>
0020 #include <iostream>
0021 
0022 namespace boost
0023 {
0024 namespace sort
0025 {
0026 namespace common
0027 {
0028 
0029 template<uint32_t NN>
0030 struct int_array
0031 {
0032     uint64_t M[NN];
0033 
0034     template<class generator>
0035     static int_array<NN> generate(generator & gen)
0036     {
0037         int_array<NN> result;
0038         for (uint32_t i = 0; i < NN; ++i)
0039         {
0040             result.M[i] = gen();
0041         };
0042         return result;
0043     };
0044 
0045     uint64_t counter(void) const
0046     {
0047         uint64_t Acc = M[0];
0048         for (uint32_t i = 1; i < NN; Acc += M[i++])
0049             ;
0050         return Acc;
0051     };
0052 };
0053 
0054 template<class IA>
0055 struct H_comp
0056 {
0057     bool operator ( )(const IA & A1, const IA & A2) const
0058     {
0059         return (A1.counter() < A2.counter());
0060     };
0061 };
0062 
0063 template<class IA>
0064 struct L_comp
0065 {
0066     bool operator ( )(const IA & A1, const IA & A2) const
0067     {
0068         return (A1.M[0] < A2.M[0]);
0069     };
0070 };
0071 //***************************************************************************
0072 };//    End namespace benchmark
0073 };//    End namespace sort
0074 };//    End namespace boost
0075 //***************************************************************************
0076 #endif // end of int_array.hpp