Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
jenkins.h
00001 ///\file 00002 00003 /****************************************************************************** 00004 The MIT License(MIT) 00005 00006 Embedded Template Library. 00007 https://github.com/ETLCPP/etl 00008 http://www.etlcpp.com 00009 00010 Copyright(c) 2014 jwellbelove 00011 00012 Permission is hereby granted, free of charge, to any person obtaining a copy 00013 of this software and associated documentation files(the "Software"), to deal 00014 in the Software without restriction, including without limitation the rights 00015 to use, copy, modify, merge, publish, distribute, sublicense, and / or sell 00016 copies of the Software, and to permit persons to whom the Software is 00017 furnished to do so, subject to the following conditions : 00018 00019 The above copyright notice and this permission notice shall be included in all 00020 copies or substantial portions of the Software. 00021 00022 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 00023 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 00024 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE 00025 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 00026 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 00027 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 00028 SOFTWARE. 00029 ******************************************************************************/ 00030 00031 #ifndef __ETL_JENKINS__ 00032 #define __ETL_JENKINS__ 00033 00034 #include <stdint.h> 00035 #include <iterator> 00036 00037 #include "platform.h " 00038 #include "static_assert.h" 00039 #include "type_traits.h " 00040 #include "error_handler.h " 00041 #include "ihash.h " 00042 #include "frame_check_sequence.h " 00043 00044 #if defined(ETL_COMPILER_KEIL) 00045 #pragma diag_suppress 1300 00046 #endif 00047 00048 ///\defgroup jenkins Jenkins 32 hash calculation 00049 ///\ingroup maths 00050 00051 namespace etl 00052 { 00053 //*************************************************************************** 00054 /// Jenkins policy. 00055 /// Calculates 32 bit Jenkins hash. 00056 //*************************************************************************** 00057 struct jenkins_policy 00058 { 00059 typedef uint32_t value_type; 00060 00061 inline uint32_t initial() 00062 { 00063 is_finalised = false; 00064 00065 return 0; 00066 } 00067 00068 inline uint32_t add(value_type hash, uint8_t value) const 00069 { 00070 ETL_ASSERT(!is_finalised, ETL_ERROR(hash_finalised)); 00071 00072 hash += value; 00073 hash += (hash << 10); 00074 hash ^= (hash >> 6); 00075 00076 return hash; 00077 } 00078 00079 inline uint32_t final(value_type hash) 00080 { 00081 hash += (hash << 3); 00082 hash ^= (hash >> 11); 00083 hash += (hash << 15); 00084 is_finalised = true; 00085 00086 return hash; 00087 } 00088 00089 bool is_finalised; 00090 }; 00091 00092 //************************************************************************* 00093 /// jenkins 00094 //************************************************************************* 00095 class jenkins : public etl::frame_check_sequence<etl::jenkins_policy> 00096 { 00097 public: 00098 00099 //************************************************************************* 00100 /// Default constructor. 00101 //************************************************************************* 00102 jenkins() 00103 { 00104 this->reset(); 00105 } 00106 00107 //************************************************************************* 00108 /// Constructor from range. 00109 /// \param begin Start of the range. 00110 /// \param end End of the range. 00111 //************************************************************************* 00112 template<typename TIterator> 00113 jenkins(TIterator begin, const TIterator end) 00114 { 00115 this->reset(); 00116 this->add(begin, end); 00117 } 00118 }; 00119 } 00120 00121 #endif 00122
Generated on Tue Jul 12 2022 14:05:42 by
