int_array.hpp 1.9 KB

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