Embedded Template Library 1.0
Loading...
Searching...
No Matches
jenkins.h
Go to the documentation of this file.
1
2
3/******************************************************************************
4The MIT License(MIT)
5
6Embedded Template Library.
7https://github.com/ETLCPP/etl
8https://www.etlcpp.com
9
10Copyright(c) 2014 John Wellbelove
11
12Permission is hereby granted, free of charge, to any person obtaining a copy
13of this software and associated documentation files(the "Software"), to deal
14in the Software without restriction, including without limitation the rights
15to use, copy, modify, merge, publish, distribute, sublicense, and / or sell
16copies of the Software, and to permit persons to whom the Software is
17furnished to do so, subject to the following conditions :
18
19The above copyright notice and this permission notice shall be included in all
20copies or substantial portions of the Software.
21
22THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
23IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
24FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE
25AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
26LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
27OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
28SOFTWARE.
29******************************************************************************/
30
31#ifndef ETL_JENKINS_INCLUDED
32#define ETL_JENKINS_INCLUDED
33
34#include "platform.h"
35#include "static_assert.h"
36#include "type_traits.h"
37#include "error_handler.h"
38#include "ihash.h"
40#include "iterator.h"
41
42#include <stdint.h>
43
44#if defined(ETL_COMPILER_KEIL)
45#pragma diag_suppress 1300
46#endif
47
50
51namespace etl
52{
53 //***************************************************************************
56 //***************************************************************************
58 {
59 typedef uint32_t value_type;
60
61 uint32_t initial() const
62 {
63 is_finalised = false;
64
65 return 0;
66 }
67
68 uint32_t add(value_type hash, uint8_t value) const
69 {
70 ETL_ASSERT(!is_finalised, ETL_ERROR(hash_finalised));
71
72 hash += value;
73 hash += (hash << 10U);
74 hash ^= (hash >> 6U);
75
76 return hash;
77 }
78
79 uint32_t final(value_type hash) const
80 {
81 hash += (hash << 3U);
82 hash ^= (hash >> 11U);
83 hash += (hash << 15U);
84 is_finalised = true;
85
86 return hash;
87 }
88
89 mutable bool is_finalised;
90 };
91
92 //*************************************************************************
94 //*************************************************************************
95 class jenkins : public etl::frame_check_sequence<etl::jenkins_policy>
96 {
97 public:
98
99 //*************************************************************************
101 //*************************************************************************
103 {
104 this->reset();
105 }
106
107 //*************************************************************************
111 //*************************************************************************
112 template<typename TIterator>
114 {
115 this->reset();
116 this->add(begin, end);
117 }
118 };
119}
120
121#endif
jenkins
Definition jenkins.h:96
jenkins()
Default constructor.
Definition jenkins.h:102
jenkins(TIterator begin, const TIterator end)
Definition jenkins.h:113
#define ETL_ASSERT(b, e)
Definition error_handler.h:316
void reset()
Resets the FCS to the initial state.
Definition frame_check_sequence.h:132
void add(TIterator begin, const TIterator end)
Definition frame_check_sequence.h:143
Definition frame_check_sequence.h:98
Definition ihash.h:64
bitset_ext
Definition absolute.h:38
ETL_CONSTEXPR TContainer::iterator begin(TContainer &container)
Definition iterator.h:962
ETL_CONSTEXPR TContainer::iterator end(TContainer &container)
Definition iterator.h:992
Definition jenkins.h:58
pair holds two objects of arbitrary type
Definition utility.h:164