24 for (
const auto& [sourcePortIndex, destinationPortIndex] : pairs) {
26 if (sourcePortIndex == -1 || destinationPortIndex == -1) {
30 if (sourcePortIndex < 0 || sourcePortIndex >=
TRANSFORMER_SIZE || destinationPortIndex < 0 ||
32 throw std::invalid_argument(
"PlugBoard error: Port index out of range (" + std::to_string(sourcePortIndex) +
33 ", " + std::to_string(destinationPortIndex) +
").");
36 if (sourcePortIndex == destinationPortIndex) {
40 if (
mapping.at(sourcePortIndex) != sourcePortIndex ||
41 mapping.at(destinationPortIndex) != destinationPortIndex) {
42 throw std::invalid_argument(
"PlugBoard error: Conflict for pair (" + std::to_string(sourcePortIndex) +
43 ", " + std::to_string(destinationPortIndex) +
"). Port already in use.");
46 mapping.at(sourcePortIndex) = destinationPortIndex;
47 mapping.at(destinationPortIndex) = sourcePortIndex;