Annotate noexcept and constexpr with HEDLEY, and add interval containment, ChaCha, and the dyadic range tables.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
Ryan Henry 2026-09-24 20:44:07 -06:00
parent 875f09fec1
commit 0d8a5a8131
97 changed files with 9212 additions and 1159 deletions

View file

@ -1,6 +1,9 @@
/// @file dpf/sequence_recipe.hpp
/// @brief
/// @details
/// @brief Compiled traversal of a sorted DPF point list.
/// @details `make_sequence_recipe` requires a nondecreasing range and throws
/// `std::runtime_error` otherwise. The recipe is independent of
/// correction words, so one recipe serves every key of that input
/// type. A sequence memoizer is bound to a particular recipe object.
/// @author Ryan Henry <ryan.henry@ucalgary.ca>
/// @author Christopher Jiang <christopher.jiang@ucalgary.ca>
/// @copyright Copyright (c) 2019-2024 Ryan Henry and [others](@ref authors)
@ -10,6 +13,8 @@
#ifndef LIBDPF_INCLUDE_DPF_SEQUENCE_RECIPE_HPP__
#define LIBDPF_INCLUDE_DPF_SEQUENCE_RECIPE_HPP__
#include "hedley/hedley.h"
#include <cstddef>
#include <type_traits>
#include <algorithm>
@ -21,6 +26,7 @@
namespace dpf
{
/// Steps, leaf count, and per-level endpoints for one sorted point list.
struct sequence_recipe
{
public:
@ -34,10 +40,21 @@ struct sequence_recipe
level_endpoints_{level_endpoints}
{ }
HEDLEY_PURE
HEDLEY_NO_THROW
constexpr const std::vector<int8_t> & recipe_steps() const noexcept { return recipe_steps_; }
HEDLEY_PURE
HEDLEY_NO_THROW
constexpr const std::vector<std::size_t> & output_indices() const noexcept { return output_indices_; }
HEDLEY_PURE
HEDLEY_NO_THROW
constexpr std::size_t num_leaf_nodes() const noexcept { return num_leaf_nodes_; }
HEDLEY_PURE
HEDLEY_NO_THROW
constexpr const std::vector<std::size_t> & level_endpoints() const noexcept { return level_endpoints_; }
/// `level_endpoints().size() - 1`. Not `constexpr`: `std::vector::size` is not a constant expression in C++17.
HEDLEY_PURE
HEDLEY_NO_THROW
std::size_t depth() const noexcept { return level_endpoints_.size()-1; }
private:
@ -122,6 +139,10 @@ auto make_sequence_recipe(ForwardIterator begin, ForwardIterator end)
} // namespace detail
/// Compile `[begin, end)` into a recipe for `DpfKey`'s input type.
/// @tparam DpfKey Key type, or a `party_key` of that key. Only the input
/// type and depth are used.
/// @throws std::runtime_error if the range is not sorted nondecreasing.
template <typename DpfKey,
typename ForwardIterator>
auto make_sequence_recipe(ForwardIterator begin, ForwardIterator end)