maiacore 1.10.1
Music analisys library
utils.h
Go to the documentation of this file.
1#pragma once
2
3#include <iostream>
4#include <numeric>
5
22template <typename T>
23void ignore(T &&) {}
24
35constexpr unsigned int hash(const char *s, int off = 0) {
36 return !s[off] ? 5381 : (hash(s, off + 1) * 33) ^ s[off];
37}
38
48constexpr int factorial(const int n) { return (n == 0) || (n == 1) ? 1 : n * factorial(n - 1); }
49
64inline bool isFloatEqual(float A, float B, float epsilon = 0.005f) {
65 return (std::fabs(A - B) < epsilon);
66}
constexpr int factorial(const int n)
Compile-time factorial calculation using recursive template evaluation.
Definition: utils.h:48
bool isFloatEqual(float A, float B, float epsilon=0.005f)
Floating-point equality comparison with epsilon tolerance for approximate matching.
Definition: utils.h:64
void ignore(T &&)
Suppresses unused variable warnings by accepting and discarding a forwarding reference.
Definition: utils.h:23
constexpr unsigned int hash(const char *s, int off=0)
Compile-time string hash function using the djb2 algorithm.
Definition: utils.h:35