Advertisement
Guest User

Untitled

a guest
Jun 26th, 2017
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 16.36 KB | None | 0 0
  1. //////////////////////////////////////////////////////////////////////////////
  2. // Testy
  3. //////////////////////////////////////////////////////////////////////////////
  4.  
  5. /*
  6.  * If you did not implement ListMap::const_iterator::operator--() set
  7.  * TEST_REVERSE_ITERATORS and SPEED_RITER_ITERATIONS to 0.
  8.  */
  9.  
  10. /* Do not touch this part */
  11. #if defined DO_TEST && ! defined DO_SPEED_TEST
  12. # define DO_SPEED_TEST           (!DO_TEST)
  13. #endif
  14. #if defined DO_SPEED_TEST && ! defined DO_TEST
  15. # define DO_TEST                 (!DO_SPEED_TEST)
  16. #endif
  17.  
  18. /* Here you can configure if you like */
  19. #ifndef DO_TEST
  20. # define DO_TEST                 1
  21. #endif
  22. #ifndef DO_SPEED_TEST
  23. # define DO_SPEED_TEST           0
  24. #endif
  25.  
  26. #if DO_TEST
  27. # define TEST_REVERSE_ITERATORS  1
  28. # define KEY_MAX                 4096
  29. # define INS_ITERATIONS          (KEY_MAX / 2)
  30. # define SET_ITERATIONS          (KEY_MAX / 2)
  31. # define ERASE_ITERATIONS        (INS_ITERATIONS / 4)
  32. # define ERASE_BY_KEY_ITERATIONS ERASE_ITERATIONS
  33. # define ERASE_RANGE_ITERATIONS  (ERASE_ITERATIONS / 2)
  34. # define ERASE_RANGE_MAX         4
  35. # define FIND_ITERATIONS         KEY_MAX
  36.  
  37. # define MAPS_COUNT              4
  38. # define SRAND_RANDOMIZE         0
  39. # define SRAND_SEED              0
  40. #endif
  41.  
  42. #if DO_SPEED_TEST
  43. # define SPEED_KEY_MAX           0
  44. # define SPEED_INS_ITERATIONS    16384
  45. # define SPEED_FIND_ITERATIONS   16384
  46. # define SPEED_ERASE_ITERATIONS  16384
  47. # define SPEED_ITER_ITERATIONS   16384
  48. # define SPEED_RITER_INS         1024
  49. # define SPEED_RITER_ITERATIONS  1024
  50.  
  51. # define SPEED_SRAND_RANDOMIZE   0
  52. # define SPEED_SRAND_SEED        0
  53. #endif
  54.  
  55.  
  56.  
  57. #include <map>
  58. #include <limits.h>
  59. #include <stdlib.h>
  60. #if SRAND_RANDOMIZE || SPEED_SRAND_RANDOMIZE
  61. # include <time.h>
  62. #endif
  63. #if DO_SPEED_TEST
  64. # include "timer.h"
  65. #endif
  66.  
  67.  
  68. typedef std::map<ListMap::Key, ListMap::Val> StdMap;
  69. typedef std::pair<ListMap, StdMap> MapPair;
  70. typedef std::pair<ListMap::iterator, bool> ListInsRet;
  71. typedef std::pair<StdMap::iterator, bool> StdInsRet;
  72.  
  73.  
  74. #if DO_TEST
  75. std::ostream &operator<<(std::ostream &os, const ListMap::P &entry) {
  76.     os << '(';
  77.     os.width(5);
  78.     return os << entry.first << ", " << entry.second << ')';
  79. }
  80.  
  81.  
  82.  
  83. /* Finds elements in maps */
  84. static std::pair<ListMap::iterator, StdMap::iterator>
  85. find(ListMap &m, StdMap &sm, const ListMap::Key &k) {
  86.     /* Find key */
  87.     ListMap::iterator it =  m.find(k);
  88.     if (it!=m.end() && it->first!=k) {
  89.         std::cerr << "searched for " << k << " but got " << *it << "\n";
  90.     }
  91.  
  92.     /* If found test with [] */
  93.     if (it!=m.end() && it->second!=m[k]) {
  94.         std::cerr << "value of find(" << k << ") (" << it->first
  95.                   << ") differs from m[" << k << "] (" << m[k] << ")\n";
  96.     }
  97.  
  98.     /* Compare with StdMap */
  99.     StdMap::iterator sit = sm.find(k);
  100.     if (sit==sm.end()) {
  101.         if (it!=m.end()) {
  102.             std::cerr << "key " << k
  103.                       << " does not exist in StdMap but exists in ListMap; "
  104.                       << *it << "\n";
  105.         }
  106.     } else if (it==m.end()) {
  107.         std::cerr << "key " << k
  108.                   << " exists in StdMap but does not exist in ListMap; "
  109.                   << *sit << "\n";
  110.     } else if (it->first!=sit->first || it->second!=sit->second) {
  111.         std::cerr << "StdMap contains " << *sit << " but ListMap contains "
  112.                   << *it << "\n";
  113.     }
  114.  
  115.     return std::make_pair(it, sit);
  116. }
  117.  
  118.  
  119.  
  120. /* Checks number of elements */
  121. static void elements(ListMap &m, StdMap &sm, bool print = true) {
  122.     if (m.size()!=sm.size()) {
  123.         std::cerr << "Number of elements " << m.size()
  124.                   << " should be " << sm.size() << "\n";
  125.     } else if (print){
  126.         std::cout << "Number of elements " << m.size() << "\n";
  127.     }
  128.     std::cout << '\n';
  129. }
  130.  
  131.  
  132.  
  133. /* Checks elements count */
  134. static void count_changed(size_t from, size_t to, size_t expected) {
  135.     if (to==expected) {
  136.         return;
  137.     }
  138.     if (from==to) {
  139.         std::cerr << "elements count stayed at " << from
  140.                   << " where should change to " << expected << '\n';
  141.         return;
  142.     }
  143.  
  144.     std::cerr << "elements count changed from " << from << " to " << to;
  145.     if (from==expected) {
  146.         std::cerr << "where should stayed at " << expected << '\n';
  147.     } else {
  148.         std::cerr << "where should change to " << expected << '\n';
  149.     }
  150. }
  151.  
  152.  
  153.  
  154. /* Inserts entry */
  155. static void insert(ListMap &m, StdMap &sm, const ListMap::Key &k,
  156.                    const ListMap::Val &v) {
  157.     const ListMap::P entry = std::make_pair(k, v);
  158.     std::cout << ":: inserting " << entry << "\n";
  159.     ListMap::iterator it = find(m, sm, k).first;
  160.  
  161.     size_t num = m.size();
  162.     ListInsRet ret = m.insert(entry);
  163.     sm.insert(entry);
  164.  
  165.     if ((it==m.end()) != ret.second) {
  166.         std::cerr << "insertion of " << entry
  167.                   << (ret.second ?  "succeed\n" : " failed\n");
  168.     }
  169.     if (ret.first->first!=k) {
  170.         std::cerr << "inserted " << k << " but got " << *ret.first << "\n";
  171.     }
  172.     if (it==m.end() && ret.first->second!=v) {
  173.         std::cerr << "inserted " << v << " but got " << *ret.first << "\n";
  174.     }
  175.     if (it!=m.end() && *ret.first!=*it) {
  176.         std::cerr << "value has changed but it shouldn't\n";
  177.     }
  178.  
  179.     count_changed(num, m.size(), num + (it==m.end()));
  180. }
  181.  
  182.  
  183.  
  184. /* Sets entry */
  185. static void set(ListMap &m, StdMap &sm, const ListMap::Key &k,
  186.                 const ListMap::Val &v) {
  187.     std::cout << ":: setting " << std::make_pair(k, v) << "\n";
  188.     bool found = find(m, sm, k).first != m.end();;
  189.  
  190.     size_t num = m.size();
  191.     m [k] = v;
  192.     sm[k] = v;
  193.     ListMap::iterator it = find(m, sm, k).first;
  194.  
  195.     if (it==m.end()) {
  196.         std::cerr << "set " << k << " but find() returns {end}\n";
  197.     } else {
  198.         if (it->first!=k) {
  199.             std::cerr << "set " << k << " but got " << *it << "\n";
  200.         }
  201.         if (it->second!=v) {
  202.             std::cerr << "set " << v << " but got " << *it << "\n";
  203.         }
  204.     }
  205.  
  206.     count_changed(num, m.size(), num + !found);
  207. }
  208.  
  209.  
  210.  
  211. /* Erases entry */
  212. static void erase(ListMap &m, StdMap &sm, const ListMap::Key &k) {
  213.     std::cout << ":: erasing " << k << "\n";
  214.     const std::pair<ListMap::iterator, StdMap::iterator> p = find(m, sm, k);
  215.     ListMap::iterator it = p.first;
  216.     StdMap::iterator sit = p.second;
  217.  
  218.     size_t num = m.size();
  219.     if (it!=m.end()) {
  220.         ListMap::iterator i2 = m.erase(it);
  221.         sm.erase(sit);
  222.     }
  223.  
  224.     count_changed(num, m.size(), num - (it!=m.end()));
  225. }
  226.  
  227.  
  228.  
  229. /* Erases entry by key */
  230. static void erase_by_key(ListMap &m, StdMap &sm, const ListMap::Key &k) {
  231.     std::cout << ":: erasing (by key) " << k << "\n";
  232.     const std::pair<ListMap::iterator, StdMap::iterator> p = find(m, sm, k);
  233.     ListMap::iterator it = p.first;
  234.     StdMap::iterator sit = p.second;
  235.     bool found = it!=m.end();
  236.  
  237.     size_t num = m.size();
  238.     int removed = m.erase(k);
  239.     sm.erase(k);
  240.  
  241.     if (found && !removed) {
  242.         std::cerr << "erase removed nothing but element was found\n";
  243.     } else if (!found && removed) {
  244.         std::cerr << "erase removed something but nothing was found\n";
  245.     }
  246.  
  247.     count_changed(num, m.size(), num - (it!=m.end()));
  248. }
  249.  
  250.  
  251.  
  252. /* Erases number of entries */
  253. static void erase_range(ListMap &m, StdMap &sm, const ListMap::Key &k,
  254.                         size_t range) {
  255.     std::cout << ":: erasing " << range << " key(s) from " << k << "\n";
  256.     const std::pair<ListMap::iterator, StdMap::iterator> p = find(m, sm, k);
  257.     ListMap::iterator it = p.first;
  258.     StdMap::iterator sit = p.second;
  259.  
  260.     ListMap::iterator end = it;
  261.     StdMap::iterator send = sit;
  262.     size_t rem = 0;
  263.     for (size_t i = range; i; --i) {
  264.         if (end!=m.end()) {
  265.             ++end;
  266.             ++rem;
  267.         }
  268.         if (send!=sm.end()) ++send;
  269.     }
  270.  
  271.     size_t num = m.size();
  272.     ListMap::iterator ret = m.erase(it, end);
  273.     sm.erase(sit, send);
  274.  
  275.     if (ret!=end) {
  276.         std::cerr << "erase returned ";
  277.         if (ret==m.end()) {
  278.             std::cerr << "{end}";
  279.         } else {
  280.             std::cerr << '{' << *ret << '}';
  281.         }
  282.         std::cerr << " where ";
  283.         if (end==m.end()) {
  284.             std::cerr << "{end}";
  285.         } else {
  286.             std::cerr << '{' << *end << '}';
  287.         }
  288.         std::cerr << " expected\n";
  289.     }
  290.  
  291.     count_changed(num, m.size(), num - rem);
  292. }
  293.  
  294.  
  295.  
  296. /* Tests iterators */
  297. static void iterators(ListMap &m, StdMap sm) {
  298.     ListMap::size_type size = m.size(), num = 0;
  299.     ListMap::iterator it = m.begin(), end = m.end();
  300.  
  301.     while (it!=end) {
  302.         const ListMap::P &entry = *it;
  303.         const StdMap::iterator sit = sm.find(entry.first);
  304.  
  305.         std::cout << ":: iterating through " << entry << "\n";
  306.         if (sit==sm.end()) {
  307.             std::cerr << "We were in " << entry << " already!\n";
  308.         } else {
  309.             sm.erase(sit);
  310.         }
  311.  
  312.         ++it;
  313.         ++num;
  314.     }
  315.  
  316.     if (num!=size) {
  317.         std::cerr << "Map contains " << size << " elements but we where in "
  318.                   << num;
  319.     }
  320. }
  321.  
  322.  
  323. /* Test reverse iterators */
  324. static void reverse_iterators(ListMap &m, StdMap sm) {
  325.     ListMap::size_type size = m.size(), num = 0;
  326.     ListMap::iterator it = m.end(), begin = m.begin();
  327.  
  328.     while (it!=begin) {
  329.         --it;
  330.         ++num;
  331.  
  332.         const ListMap::P &entry = *it;
  333.         const StdMap::iterator sit = sm.find(entry.first);
  334.  
  335.         std::cout << ":: iterating in reverse through " << entry << "\n";
  336.         if (sit==sm.end()) {
  337.             std::cerr << "We were in " << entry << " already!\n";
  338.         } else {
  339.             sm.erase(sit);
  340.         }
  341.     }
  342.  
  343.     if (num!=size) {
  344.         std::cerr << "Map contains " << size << " elements but we where in "
  345.                   << num;
  346.     }
  347. }
  348.  
  349.  
  350.  
  351. /* Compare two maps */
  352. #if MAPS_COUNT > 1
  353. static void compare(unsigned id1, unsigned id2, ListMap &m1, ListMap &m2,
  354.                     bool result) {
  355.     bool equal = m1.struct_eq(m2);
  356.     bool identical = m1.info_eq(m2);
  357.  
  358.     if (equal!=m2.info_eq(m1)) {
  359.         std::cerr << '#' << id1 << (equal ? " == " : " != ") << '#' << id2
  360.                   << " but #" << id2 << (equal ? " != " : " == ") << '#' << id1
  361.                   << '\n';
  362.     }
  363.  
  364.     if (identical!=m2.struct_eq(m1)) {
  365.         std::cerr << '#' << id1 << (identical ? " === " : " !== ") << '#' << id2
  366.                   << " but #" << id2 << (identical ? " !== " : " === ") << '#'
  367.                   << id1 << '\n';
  368.     }
  369.  
  370.     if (identical && !equal) {
  371.         std::cerr << "#" << id1 << " === #" << id2 << " but #" << id1 << " != #"
  372.                   << id2 << '\n';
  373.     }
  374.  
  375.     if (equal && m1.size() != m2.size()) {
  376.         std::cerr << "#" << id1 << " == #" << id2 << " but size(#" << id1
  377.                   << ") == " << m1.size() << " != " << m2.size()
  378.                   << " == size(#" << id2 << ")\n";
  379.     }
  380.  
  381.     if (equal!=result) {
  382.         std::cerr << '#' << id1 << (equal ? " == " : " != ") << '#' << id2
  383.                   << " but expected otherwise\n";
  384.     }
  385. }
  386. #endif
  387.  
  388.  
  389. #undef RAND_KEY
  390. #if KEY_MAX
  391. # define RAND_KEY (rand() % KEY_MAX - KEY_MAX/2)
  392. #else
  393. # define RAND_KEY (rand() - RAND_MAX/2)
  394. #endif
  395.  
  396.  
  397. /* Test function */
  398. static void test(void) {
  399.     /* Init */
  400.     MapPair m[MAPS_COUNT];
  401.     unsigned i, j, k;
  402.  
  403. #if SRAND_RANDOMIZE
  404.     srand(time(0));
  405. #else
  406.     srand(SRAND_SEED);
  407. #endif
  408.  
  409.  
  410.     /* All should compare equal */
  411. #if MAPS_COUNT > 1
  412.     for (i = 0; i<(sizeof(m)/sizeof(*m)); ++i) {
  413.         for (j = 0; j<(sizeof(m)/sizeof(*m)); ++j) {
  414.             compare(i, j, m[i].first, m[j].first, true);
  415.         }
  416.     }
  417.     std::cout << '\n';
  418. #endif
  419.  
  420.  
  421.     /* Main test */
  422.     for (k = 0; k<(sizeof(m)/sizeof(*m)); ++k) {
  423.         std::cout << "=== Operates on map #" << k << " ===\n\n";
  424.  
  425.         /* Insert */
  426.         for (i = 0; i<INS_ITERATIONS; ++i) {
  427.             char str[9];
  428.             for (j = 0; j<8; ++j) str[j] = 'A' + rand() % 26;
  429.             str[j] = 0;
  430.             insert(m[k].first, m[k].second, RAND_KEY, str);
  431.         }
  432.         elements(m[k].first, m[k].second);
  433.  
  434.         /* Set */
  435.         for (i = 0; i<INS_ITERATIONS; ++i) {
  436.             char str[9];
  437.             for (j = 0; j<8; ++j) str[j] = 'A' + rand() % 26;
  438.             str[j] = 0;
  439.             set(m[k].first, m[k].second, RAND_KEY, str);
  440.         }
  441.         elements(m[k].first, m[k].second);
  442.  
  443.         /* Erase */
  444.         for (i = 0; i<ERASE_ITERATIONS; ++i) {
  445.             erase(m[k].first, m[k].second, RAND_KEY);
  446.         }
  447.         elements(m[k].first, m[k].second);
  448.  
  449.         /* Erase by key */
  450.         for (i = 0; i<ERASE_BY_KEY_ITERATIONS; ++i) {
  451.             erase_by_key(m[k].first, m[k].second, RAND_KEY);
  452.         }
  453.         elements(m[k].first, m[k].second);
  454.  
  455.         /* Erase range */
  456.         for (i = 0; i<ERASE_BY_KEY_ITERATIONS; ++i) {
  457.             erase_range(m[k].first, m[k].second, RAND_KEY,
  458.                         rand() % ERASE_RANGE_MAX);
  459.         }
  460.         elements(m[k].first, m[k].second);
  461.  
  462.         /* Find */
  463. #if FIND_ITERATIONS >= KEY_MAX
  464.         for (i = 0; i < KEY_MAX; ++i) {
  465.             find(m[k].first, m[k].second, i);
  466.         }
  467. #else
  468.         for (i = 0; i < FIND_ITERATIONS; ++i) {
  469.             find(m[k].first, m[k].second, RAND_KEY);
  470.         }
  471. #endif
  472.  
  473.         /* Iterators */
  474.         iterators(m[k].first, m[k].second);
  475. #if TEST_REVERSE_ITERATORS
  476.         reverse_iterators(m[k].first, m[k].second);
  477. #endif
  478.     }
  479.  
  480.  
  481. #if MAPS_COUNT > 1
  482.     /* Compare */
  483.     for (i = 0; i<(sizeof(m)/sizeof(*m)); ++i) {
  484.         for (j = 0; j<(sizeof(m)/sizeof(*m)); ++j) {
  485.             compare(i, j, m[i].first, m[j].first, i==j || m[i].second==m[j].second);
  486.         }
  487.     }
  488.     std::cout << '\n';
  489.  
  490.  
  491.     /* Create two equal maps */
  492.     std::cout << "=== Creating two equal maps ===\n\n";
  493.     m[0].first.clear(); m[0].second.clear();
  494.     m[1].first.clear(); m[1].second.clear();
  495.  
  496.     compare(0, 0, m[0].first, m[0].first, true);
  497.     compare(0, 1, m[0].first, m[1].first, true);
  498.     compare(1, 0, m[1].first, m[0].first, true);
  499.     compare(1, 1, m[1].first, m[1].first, true);
  500.  
  501.     /* Insert */
  502.     for (i = 0; i<INS_ITERATIONS; ++i) {
  503.         ListMap::Key key = RAND_KEY;
  504.         char str[9];
  505.         for (j = 0; j<8; ++j) str[j] = 'A' + rand() % 26;
  506.         str[j] = 0;
  507.         insert(m[0].first, m[0].second, key, str);
  508.         insert(m[1].first, m[1].second, key, str);
  509.     }
  510.     elements(m[0].first, m[0].second);
  511.     elements(m[1].first, m[1].second);
  512.  
  513.     /* Set */
  514.     for (i = 0; i<INS_ITERATIONS; ++i) {
  515.         ListMap::Key key = RAND_KEY;
  516.         char str[9];
  517.         for (j = 0; j<8; ++j) str[j] = 'A' + rand() % 26;
  518.         str[j] = 0;
  519.         set(m[0].first, m[0].second, key, str);
  520.         set(m[1].first, m[1].second, key, str);
  521.     }
  522.     elements(m[0].first, m[0].second);
  523.     elements(m[1].first, m[1].second);
  524.  
  525.     /* Compare */
  526.     compare(0, 0, m[0].first, m[0].first, true);
  527.     compare(0, 1, m[0].first, m[1].first, true);
  528.     compare(1, 0, m[1].first, m[0].first, true);
  529.     compare(1, 1, m[1].first, m[1].first, true);
  530. #endif
  531.  
  532.     /* Copy constructor test */
  533.     std::cout << "=== Cloning #0 to #666 ===\n";
  534.     ListMap *clone = new ListMap(m[0].first);
  535.     compare(0, 666, m[0].first, *clone, true);
  536.     compare(0, 666, *clone, m[0].first, true);
  537.     delete clone;
  538. }
  539. #endif /* DO_TEST */
  540.  
  541.  
  542.  
  543. /* Speed test */
  544. #if DO_SPEED_TEST
  545.  
  546.  
  547. #undef RAND_KEY
  548. #if SPEED_KEY_MAX
  549. # define RAND_KEY (rand() % SPEED_KEY_MAX - SPEED_KEY_MAX/2)
  550. #else
  551. # define RAND_KEY (rand() - RAND_MAX/2)
  552. #endif
  553.  
  554.  
  555. #define PRINT_TIME(str) do {                            \
  556.         double _time = timer_stop(timer);               \
  557.         std::cout.width(20);                            \
  558.         std::cout << std::left << (str) << ": ";        \
  559.         std::cout.precision(8);                         \
  560.         std::cout << std::showpoint <<_time << " s\n";  \
  561.     } while (0)
  562.  
  563.  
  564. static void speed_test() {
  565.     /* Init */
  566.     ListMap m;
  567.     unsigned i;
  568.     struct time_m timer;
  569.  
  570. #if SPEED_SRAND_RANDOMIZE
  571.     srand(time(0));
  572. #else
  573.     srand(SPEED_SRAND_SEED);
  574. #endif
  575.  
  576.     /* Insert */
  577.     timer = timer_start();
  578.     for (i = 0; i<SPEED_INS_ITERATIONS; ++i) {
  579.         m.insert(std::make_pair(RAND_KEY, ""));
  580.     }
  581.     PRINT_TIME("Insert");
  582.  
  583.     /* Find */
  584.     timer = timer_start();
  585.     for (i = 0; i<SPEED_FIND_ITERATIONS; ++i) {
  586.         m.find(RAND_KEY);
  587.     }
  588.     PRINT_TIME("Find");
  589.  
  590.     /* Erase */
  591.     timer = timer_start();
  592.     for (i = 0; i<SPEED_ERASE_ITERATIONS; ++i) {
  593.         m.erase(RAND_KEY);
  594.     }
  595.     PRINT_TIME("Erase");
  596.  
  597.     /* Clear */
  598.     timer = timer_start();
  599.     m.clear();
  600.     PRINT_TIME("Clear");
  601.  
  602.     /* Insert */
  603.     timer = timer_start();
  604.     for (i = 0; i<SPEED_INS_ITERATIONS; ++i) {
  605.         m.insert(std::make_pair(RAND_KEY, ""));
  606.     }
  607.     PRINT_TIME("Insert");
  608.  
  609.     /* Iterators */
  610.     timer = timer_start();
  611.     for (i = 0; i<SPEED_ITER_ITERATIONS; ++i) {
  612.         const ListMap::const_iterator end = m.end();
  613.         ListMap::const_iterator it = m.begin();
  614.         for (; it!=end; ++it);
  615.     }
  616.     PRINT_TIME("Iterators");
  617.  
  618.     /* Find + Erase */
  619.     timer = timer_start();
  620.     for (i = 0; i<SPEED_ERASE_ITERATIONS; ++i) {
  621.         m.erase(m.find(RAND_KEY));
  622.     }
  623.     PRINT_TIME("Find + erase");
  624.  
  625.     /* Reverse iterators */
  626. #if SPEED_RITER_ITERATIONS
  627.     timer = timer_start();
  628.     m.clear();
  629.     PRINT_TIME("Clear");
  630.  
  631.     /* Insert */
  632.     timer = timer_start();
  633.     for (i = 0; i<SPEED_RITER_INS; ++i) {
  634.         m.insert(std::make_pair(RAND_KEY, ""));
  635.     }
  636.     PRINT_TIME("Insert (riter)");
  637.  
  638.     timer = timer_start();
  639.     for (i = 0; i<SPEED_RITER_ITERATIONS; ++i) {
  640.         const ListMap::const_iterator begin = m.begin();
  641.         ListMap::const_iterator it = m.end();
  642.         for (; it!=begin; --it);
  643.     }
  644.     PRINT_TIME("Reverse iterators");
  645. #endif
  646.  
  647. }
  648. #endif /* DO_SPEED_TEST */
  649.  
  650.  
  651.  
  652. /* Main */
  653. int main(void) {
  654. #if DO_TEST
  655.     test();
  656.     if (CCount::getCount()) {
  657.         std::cerr << "count = " << CCount::getCount()
  658.                   << "; should be 0; memory leak\n";
  659.     } else {
  660.         std::cout << "count = " << CCount::getCount() << "\n";
  661.     }
  662. #endif
  663.  
  664. #if DO_SPEED_TEST
  665.     speed_test();
  666. #endif
  667.  
  668.     return 0;
  669. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement