int_array.hpp 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  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 ([email protected] )\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. #include <ciso646>
  18. #include <cstdint>
  19. #include <iostream>
  20. namespace boost
  21. {
  22. namespace sort
  23. {
  24. namespace common
  25. {
  26. template<uint32_t NN>
  27. struct int_array
  28. {
  29. uint64_t M[NN];
  30. template<class generator>
  31. static int_array<NN> generate(generator & gen)
  32. {
  33. int_array<NN> result;
  34. for (uint32_t i = 0; i < NN; ++i)
  35. {
  36. result.M[i] = gen();
  37. };
  38. return result;
  39. };
  40. uint64_t counter(void) const
  41. {
  42. uint64_t Acc = M[0];
  43. for (uint32_t i = 1; i < NN; Acc += M[i++])
  44. ;
  45. return Acc;
  46. };
  47. };
  48. template<class IA>
  49. struct H_comp
  50. {
  51. bool operator ( )(const IA & A1, const IA & A2) const
  52. {
  53. return (A1.counter() < A2.counter());
  54. };
  55. };
  56. template<class IA>
  57. struct L_comp
  58. {
  59. bool operator ( )(const IA & A1, const IA & A2) const
  60. {
  61. return (A1.M[0] < A2.M[0]);
  62. };
  63. };
  64. //***************************************************************************
  65. };// End namespace benchmark
  66. };// End namespace sort
  67. };// End namespace boost
  68. //***************************************************************************
  69. #endif // end of int_array.hpp