Commit b8e4a5f8 authored by Jakob Bornecrantz's avatar Jakob Bornecrantz

aux/math: Add simple string hashing function

parent 918b834a
......@@ -4,8 +4,9 @@
set(MATH_SOURCE_FILES
math/m_api.h
math/m_base.cpp
math/m_optics.c
math/m_eigen_interop.h
math/m_hash.cpp
math/m_optics.c
math/m_quatexpmap.cpp
)
......
......@@ -36,6 +36,25 @@ extern "C" {
*/
/*
*
* Hash functions.
*
*/
/*!
* Generate a hash value from the given string, trailing zero not included.
*
* Hashing function used is not specified so no garantee of staying the same
* between different versions of the software, or even when the same version
* is compiled on different platforms/libc++ as it might use std::hash.
*
* @ingroup aux_math
*/
size_t
math_hash_string(const char *str_c, size_t length);
/*
*
* Vector functions
......
// Copyright 2019, Collabora, Ltd.
// SPDX-License-Identifier: BSL-1.0
/*!
* @file
* @brief Hashing fuction.
* @author Jakob Bornecrantz <jakob@collabora.com>
* @ingroup aux_math
*/
#include <string>
#include "m_api.h"
extern "C" size_t
math_hash_string(const char *str_c, size_t length)
{
std::string str = std::string(str_c, length);
std::hash<std::string> str_hash;
return str_hash(str);
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment