boostorg / heap

Boost.Heap
https://boost.org/libs/heap
18 stars 39 forks source link

ordered iteration is wrong with duplicate keys #33

Open llxxee opened 2 years ago

llxxee commented 2 years ago

To repro: https://godbolt.org/z/jbK7nz37E

#include <iostream>
#include <boost/heap/binomial_heap.hpp>

int main()
{
  boost::heap::binomial_heap<int> heap;
  heap.push(100);
  heap.push(100);

  int count = 0;
  for (auto it = heap.ordered_begin();
        it != heap.ordered_end();
        ++it) {
    std::cout << *it << std::endl;
    count++;
  }

  // expected 2, got 3
  std::cout << count << std::endl;
}