test/heap_test.h
changeset 2230 67af33b34394
parent 1956 a055123339d5
child 2242 16523135943d
equal deleted inserted replaced
4:bb2aa1a04dc4 5:815a1f901537
    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] = rand() % 1000;
    48     v[i] = rnd.getInt(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] = rand() % 1000;
    68     v[i] = rnd.getInt(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] += rand() % 1000;
    72     v[i] += rnd.getInt(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.");