Loading...
Searching...
No Matches
jenkins.h
Go to the documentation of this file.
/******************************************************************************
The MIT License(MIT)
Embedded Template Library.
https://github.com/ETLCPP/etl
https://www.etlcpp.com
Copyright(c) 2014 John Wellbelove
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files(the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and / or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions :
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
******************************************************************************/
#ifndef ETL_JENKINS_INCLUDED
#define ETL_JENKINS_INCLUDED
#include "platform.h"
#include "error_handler.h"
#include "frame_check_sequence.h"
#include "ihash.h"
#include "iterator.h"
#include "type_traits.h"
#include <stdint.h>
#if defined(ETL_COMPILER_KEIL)
#pragma diag_suppress 1300
#endif
namespace etl
{
//***************************************************************************
//***************************************************************************
struct jenkins_policy
{
typedef uint32_t value_type;
uint32_t initial() const
{
is_finalised = false;
return 0;
}
uint32_t add(value_type hash, uint8_t value) const
{
ETL_ASSERT(!is_finalised, ETL_ERROR(hash_finalised));
hash += value;
hash += (hash << 10U);
hash ^= (hash >> 6U);
return hash;
}
uint32_t final(value_type hash) const
{
hash += (hash << 3U);
hash ^= (hash >> 11U);
hash += (hash << 15U);
is_finalised = true;
return hash;
}
mutable bool is_finalised;
};
//*************************************************************************
//*************************************************************************
class jenkins : public etl::frame_check_sequence<etl::jenkins_policy>
{
public:
//*************************************************************************
//*************************************************************************
jenkins()
{
this->reset();
}
//*************************************************************************
//*************************************************************************
template <typename TIterator>
jenkins(TIterator begin, const TIterator end)
{
this->reset();
this->add(begin, end);
}
};
} // namespace etl
#endif
etl::jenkins::jenkins
jenkins()
Default constructor.
Definition jenkins.h:101
etl::jenkins::jenkins
jenkins(TIterator begin, const TIterator end)
Definition jenkins.h:112
error_handler.h
frame_check_sequence.h
ETL_ASSERT
#define ETL_ASSERT(b, e)
Definition error_handler.h:511
etl::frame_check_sequence< etl::jenkins_policy >::add
ETL_CONSTEXPR14 void add(TIterator begin, const TIterator end)
Definition frame_check_sequence.h:145
etl::frame_check_sequence< etl::jenkins_policy >::reset
ETL_CONSTEXPR14 void reset()
Definition frame_check_sequence.h:134
etl::frame_check_sequence
Definition frame_check_sequence.h:98
etl::hash_finalised
Definition ihash.h:63
ihash.h
iterator.h
etl
Definition absolute.h:40
etl::end
TContainer::iterator end(TContainer &container)
Definition iterator.h:1166
etl::begin
TContainer::iterator begin(TContainer &container)
Definition iterator.h:1136
platform.h
etl::jenkins_policy
Definition jenkins.h:57
type_traits.h