~aleteoryx/muditaos

ref: 182f694ac2a1c3da23df72e0494588fc579e7616 muditaos/module-apps/locks/widgets/LockHash.hpp -rw-r--r-- 722 bytes
182f694a — Przemyslaw Brudny [EGD-6637] Cleanup locks structure 4 years ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md

#pragma once

#include <cstdint>
#include <vector>
#include <functional>

template <> struct std::hash<std::vector<unsigned int>>
{
    const static unsigned int digit_multiplier = 10;
    uint32_t operator()(std::vector<unsigned int> const &input) const noexcept
    {
        uint32_t value = 0;
        for (auto i : input) {
            value = digit_multiplier * value + i;
        }
        return value;
    }
};

static inline uint32_t getHash(const std::vector<unsigned int> &input)
{
    static std::hash<std::vector<unsigned int>> hashEngine;
    return hashEngine(input);
}