test/heap_test.h
changeset 2262 b9a7f4115abe
parent 2229 4dbb6dd2dd4b
child 2269 fb1c634fff29
equal deleted inserted replaced
5:815a1f901537 6:091df660a30e
    43   Heap heap(map);
    43   Heap heap(map);
    44   
    44   
    45   std::vector<int> v(n);
    45   std::vector<int> v(n);
    46 
    46 
    47   for (int i = 0; i < n; ++i) {
    47   for (int i = 0; i < n; ++i) {
    48     v[i] = rnd.getInt(1000);
    48     v[i] = rnd[1000];
    49     heap.push(i, v[i]);
    49     heap.push(i, v[i]);
    50   }
    50   }
    51   std::sort(v.begin(), v.end());
    51   std::sort(v.begin(), v.end());
    52   for (int i = 0; i < n; ++i) {
    52   for (int i = 0; i < n; ++i) {
    53     check(v[i] == heap.prio() ,"Wrong order in heap sort.");
    53     check(v[i] == heap.prio() ,"Wrong order in heap sort.");
    63   Heap heap(map);
    63   Heap heap(map);
    64   
    64   
    65   std::vector<int> v(n);
    65   std::vector<int> v(n);
    66 
    66 
    67   for (int i = 0; i < n; ++i) {
    67   for (int i = 0; i < n; ++i) {
    68     v[i] = rnd.getInt(1000);
    68     v[i] = rnd[1000];
    69     heap.push(i, v[i]);
    69     heap.push(i, v[i]);
    70   }
    70   }
    71   for (int i = 0; i < n; ++i) {
    71   for (int i = 0; i < n; ++i) {
    72     v[i] += rnd.getInt(1000);
    72     v[i] += rnd[1000];
    73     heap.increase(i, v[i]);
    73     heap.increase(i, v[i]);
    74   }
    74   }
    75   std::sort(v.begin(), v.end());
    75   std::sort(v.begin(), v.end());
    76   for (int i = 0; i < n; ++i) {
    76   for (int i = 0; i < n; ++i) {
    77     check(v[i] == heap.prio() ,"Wrong order in heap increase test.");
    77     check(v[i] == heap.prio() ,"Wrong order in heap increase test.");