@@ -41,11 +41,6 @@ struct diving_root_t {
4141 {
4242 return a.node .lower_bound > b.node .lower_bound ;
4343 }
44-
45- friend bool operator <(const diving_root_t <i_t , f_t >& a, const diving_root_t <i_t , f_t >& b)
46- {
47- return a.node .lower_bound < b.node .lower_bound ;
48- }
4944};
5045
5146// A min-heap for storing the starting nodes for the dives.
@@ -57,22 +52,14 @@ class diving_queue_t {
5752 std::vector<diving_root_t <i_t , f_t >> buffer;
5853 static constexpr i_t max_size_ = 256 ;
5954
60- void discard_worst_node ()
61- {
62- auto max_it = std::max_element (buffer.begin (), buffer.end (), std::less<>());
63- std::swap (*max_it, buffer.back ());
64- buffer.pop_back ();
65- std::make_heap (buffer.begin (), buffer.end (), std::greater<>());
66- }
67-
6855 public:
6956 diving_queue_t () { buffer.reserve (max_size_); }
7057
7158 void push (diving_root_t <i_t , f_t >&& node)
7259 {
7360 buffer.push_back (std::move (node));
7461 std::push_heap (buffer.begin (), buffer.end (), std::greater<>());
75- if (buffer.size () > max_size ()) { discard_worst_node (); }
62+ if (buffer.size () > max_size ()) { buffer. pop_back (); }
7663 }
7764
7865 void emplace (mip_node_t <i_t , f_t >&& node,
@@ -81,12 +68,11 @@ class diving_queue_t {
8168 {
8269 buffer.emplace_back (std::move (node), lower, upper);
8370 std::push_heap (buffer.begin (), buffer.end (), std::greater<>());
84- if (buffer.size () > max_size ()) { discard_worst_node (); }
71+ if (buffer.size () > max_size ()) { buffer. pop_back (); }
8572 }
8673
8774 diving_root_t <i_t , f_t > pop ()
8875 {
89- assert (!buffer.empty () && " Cannot pop from an empty queue!" );
9076 std::pop_heap (buffer.begin (), buffer.end (), std::greater<>());
9177 diving_root_t <i_t , f_t > node = std::move (buffer.back ());
9278 buffer.pop_back ();
@@ -95,13 +81,7 @@ class diving_queue_t {
9581
9682 i_t size () const { return buffer.size (); }
9783 constexpr i_t max_size () const { return max_size_; }
98-
99- const diving_root_t <i_t , f_t >& top () const
100- {
101- assert (!buffer.empty () && " Cannot get top from an empty queue!" );
102- return buffer.front ();
103- }
104-
84+ const diving_root_t <i_t , f_t >& top () const { return buffer.front (); }
10585 void clear () { buffer.clear (); }
10686};
10787
0 commit comments