annotate enigma/enigma_utils.h @ 3:f4e25e6b76c3

Created plugboard class and tests.
author Brian Neal <bgneal@gmail.com>
date Sat, 23 Jun 2012 23:28:17 -0500
parents 1459e74fda3f
children 2792ca4ffa84
rev   line source
bgneal@1 1 #ifndef CPP_ENIGMA_ENIGMA_UTILS_H
bgneal@1 2 #define CPP_ENIGMA_ENIGMA_UTILS_H
bgneal@1 3 // Copyright (C) 2012 by Brian Neal.
bgneal@1 4 // This file is part of Cpp-Enigma, the Enigma Machine simulation.
bgneal@1 5 // Cpp-Enigma is released under the MIT License (see License.txt).
bgneal@1 6 //
bgneal@1 7 // enigma_utils.h - This file contains common functions used throughout Cpp-Enigma.
bgneal@1 8
bgneal@1 9 namespace enigma
bgneal@1 10 {
bgneal@1 11 // This version of mod acts like Python's with respect to negative dividends.
bgneal@1 12 inline int alpha_mod(int dividend)
bgneal@1 13 {
bgneal@1 14 if (dividend < 0)
bgneal@1 15 {
bgneal@1 16 dividend += 26;
bgneal@1 17 }
bgneal@1 18 return dividend % 26;
bgneal@1 19 }
bgneal@1 20 }
bgneal@1 21
bgneal@1 22 #endif