WPILibC++ 2023.4.3-108-ge5452e3
DJB.h
Go to the documentation of this file.
1//===-- llvm/Support/DJB.h ---DJB Hash --------------------------*- C++ -*-===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8//
9// This file contains support for the DJ Bernstein hash function.
10//
11//===----------------------------------------------------------------------===//
12
13#ifndef WPIUTIL_WPI_DJB_H
14#define WPIUTIL_WPI_DJB_H
15
16#include <string_view>
17
18namespace wpi {
19
20/// The Bernstein hash function used by the DWARF accelerator tables.
21inline uint32_t djbHash(std::string_view Buffer, uint32_t H = 5381) {
22 for (unsigned char C : Buffer)
23 H = (H << 5) + H + C;
24 return H;
25}
26
27} // namespace wpi
28
29#endif // WPIUTIL_WPI_DJB_H
basic_string_view< char > string_view
Definition: core.h:520
::uint32_t uint32_t
Definition: Meta.h:56
Definition: AprilTagFieldLayout.h:18
uint32_t djbHash(std::string_view Buffer, uint32_t H=5381)
The Bernstein hash function used by the DWARF accelerator tables.
Definition: DJB.h:21