Add a swap function

This commit is contained in:
Segcolt 2024-10-12 15:03:28 -03:00
parent 55008b3e40
commit 7dbfdde3f1

9
sa.hpp
View File

@ -49,10 +49,17 @@ class solution {
}
void randomize() {
shuffle(items.begin(), items.end(), gen);
std::shuffle(items.begin(), items.end(), gen);
fitness = calculate_boxes();
}
void swap(solution &other) {
std::swap(fitness, other.fitness);
std::swap(items, other.items);
std::swap(capacity, other.capacity);
std::swap(gen, other.gen);
}
};
} // namespace sa