- while (size_ > BUCKET_SIZE) {
- nodes.pop_back();
- size_--;
- }
- xbt_assert(nodes.size() == size_, "Wrong size for the answer");
+ // sort by distance
+ std::sort(nodes_.begin(), nodes_.end(),
+ [](const std::pair<unsigned int, unsigned int>& a, const std::pair<unsigned int, unsigned int>& b) {
+ return (a.second < b.second);
+ });
+ if (nodes_.size() > BUCKET_SIZE)
+ nodes_.resize(BUCKET_SIZE);