Mercurial > public > cpp-enigma
annotate enigma/enigma_utils.cpp @ 9:7362965f53b1
Added tests for the hill climbing functions in the plugboard class.
author | Brian Neal <bgneal@gmail.com> |
---|---|
date | Fri, 29 Jun 2012 21:19:00 -0500 |
parents | 2792ca4ffa84 |
children | 424111a36ed7 |
rev | line source |
---|---|
bgneal@4 | 1 // Copyright (C) 2012 by Brian Neal. |
bgneal@4 | 2 // This file is part of Cpp-Enigma, the Enigma Machine simulation. |
bgneal@4 | 3 // Cpp-Enigma is released under the MIT License (see License.txt). |
bgneal@4 | 4 // |
bgneal@4 | 5 // enigma_utils.cpp - Implementation file for enigma_utils.h. |
bgneal@4 | 6 |
bgneal@4 | 7 #include "enigma_utils.h" |
bgneal@4 | 8 |
bgneal@4 | 9 std::string enigma::remove_spaces(const std::string& s) |
bgneal@4 | 10 { |
bgneal@4 | 11 std::string result; |
bgneal@4 | 12 result.reserve(s.size()); |
bgneal@4 | 13 |
bgneal@4 | 14 for (const auto& c : s) |
bgneal@4 | 15 { |
bgneal@4 | 16 if (c != ' ') |
bgneal@4 | 17 { |
bgneal@4 | 18 result += c; |
bgneal@4 | 19 } |
bgneal@4 | 20 } |
bgneal@4 | 21 return result; |
bgneal@4 | 22 } |