# HG changeset patch # User Brian Neal # Date 1341023184 18000 # Node ID 232dbe7a3fe0f9c8f8796a59c4c99808087ae8c8 # Parent 7362965f53b125cd4ff502a61fbef234991b914f Added plugboard::unplug_all(). diff -r 7362965f53b1 -r 232dbe7a3fe0 enigma/plugboard.h --- a/enigma/plugboard.h Fri Jun 29 21:19:00 2012 -0500 +++ b/enigma/plugboard.h Fri Jun 29 21:26:24 2012 -0500 @@ -152,6 +152,15 @@ return wiring_map[x] == y && wiring_map[y] == x; } + // Unplugs all cables + void unplug_all() + { + for (auto i = 0U; i < wiring_map.size(); ++i) + { + wiring_map[i] = i; + } + } + private: alpha_int_array wiring_map; diff -r 7362965f53b1 -r 232dbe7a3fe0 enigma/tests/test_plugboard.t.h --- a/enigma/tests/test_plugboard.t.h Fri Jun 29 21:19:00 2012 -0500 +++ b/enigma/tests/test_plugboard.t.h Fri Jun 29 21:26:24 2012 -0500 @@ -307,4 +307,22 @@ } } + void test_unplug_all() + { + plugboard pb; + pb.connect(5, 7); + pb.connect(1, 20); + pb.connect(18, 24); + pb.unplug_all(); + for (int i = 0; i < 26; ++i) + { + TS_ASSERT(pb.is_free(i)); + } + pb.unplug_all(); + for (int i = 0; i < 26; ++i) + { + TS_ASSERT(pb.is_free(i)); + } + } + };