| 1 | // -*- C++ -*-cxx . . $ `<file>/vendor/Heap-Layers/utility/modulo.h`/ |
| 2 | |
| 3 | #ifndef HL_MODULO_H |
| 4 | #define HL_MODULO_Hcxx . . $ `vendor/Heap-Layers/utility/modulo.h:4:9`! |
| 5 | |
| 6 | /// A templated class that provides faster modulo functions when the |
| 7 | /// argument is a power of two. |
| 8 | |
| 9 | #include <stdlib.h> |
| 10 | #include "checkpoweroftwo.h"cxx . . $ `<file>/vendor/Heap-Layers/utility/checkpoweroftwo.h`/ |
| 11 | |
| 12 | namespace HLcxx . . $ HL/ { |
| 13 | |
| 14 | template <size_t Modulus> |
| 15 | class Modulocxx . . $ HL/Modulo#; |
| 16 | |
| 17 | template <size_t Modulus> |
| 18 | class Modulocxx . . $ HL/Modulo# { |
| 19 | public: |
| 20 | template <class TYPE> |
| 21 | static TYPE modcxx . . $ HL/Modulo#mod(f3ae8df5ec0ce6c7). (TYPE m) { |
| 22 | if (IsPowerOfTwocxx . . $ HL/IsPowerOfTwo#<Modulus>::VALUE) { |
| 23 | return m & (Modulus - 1); |
| 24 | } else { |
| 25 | return m % Modulus; |
| 26 | } |
| 27 | } |
| 28 | }; |
| 29 | |
| 30 | } |
| 31 | |
| 32 | #endif |