7#if !defined(TETENGO_LATTICE_NODE_HPP)
8#define TETENGO_LATTICE_NODE_HPP
15#include <boost/operators.hpp>
26 class node :
public boost::equality_comparable<node>
40 [[nodiscard]]
static node bos(
const std::vector<int>* p_preceding_edge_costs);
54 [[nodiscard]]
static node
56 const std::vector<int>* p_preceding_edge_costs,
77 const std::any* p_value,
80 const std::vector<int>* p_preceding_edge_costs,
88 m_p_preceding_edge_costs{ p_preceding_edge_costs },
110 const std::vector<int>* p_preceding_edge_costs,
153 [[nodiscard]]
constexpr const std::any&
value()
const
166 return m_index_in_step;
176 return m_preceding_step;
186 assert(m_p_preceding_edge_costs);
187 return *m_p_preceding_edge_costs;
197 return m_best_preceding_node;
232 const input* m_p_key;
234 const std::any* m_p_value;
236 std::size_t m_index_in_step;
238 std::size_t m_preceding_step;
240 const std::vector<int>* m_p_preceding_edge_costs;
242 std::size_t m_best_preceding_node;
An entry view.
Definition entry.hpp:110
An entry.
Definition entry.hpp:26
A node.
Definition node.hpp:27
constexpr node(const input *p_key, const std::any *p_value, std::size_t index_in_step, std::size_t preceding_step, const std::vector< int > *p_preceding_edge_costs, std::size_t best_preceding_node, int node_cost, int path_cost)
Creates a node.
Definition node.hpp:75
bool is_bos() const
Returns true is this node is the BOS.
constexpr std::size_t index_in_step() const
Returns the index in the step.
Definition node.hpp:164
constexpr int node_cost() const
Returns the node cost.
Definition node.hpp:205
static node eos(std::size_t preceding_step, const std::vector< int > *p_preceding_edge_costs, std::size_t best_preceding_node, int path_cost)
Returns an EOS (End of Sequence).
static node bos(const std::vector< int > *p_preceding_edge_costs)
Returns the BOS (Beginning of Sequence).
constexpr std::size_t preceding_step() const
Returns the preceding step.
Definition node.hpp:174
friend constexpr bool operator==(const node &one, const node &another)
Returns true if one node is equal to another.
Definition node.hpp:129
constexpr int path_cost() const
Returns the path cost.
Definition node.hpp:215
constexpr const input * p_key() const
Returns the key.
Definition node.hpp:143
constexpr const std::vector< int > & preceding_edge_costs() const
Returns the preceding edge costs.
Definition node.hpp:184
constexpr const std::any & value() const
Returns the value.
Definition node.hpp:153
constexpr node(const entry_view &entry, std::size_t index_in_step, std::size_t preceding_step, const std::vector< int > *p_preceding_edge_costs, std::size_t best_preceding_node, int path_cost)
Creates a node from a vocabulary entry.
Definition node.hpp:106
constexpr std::size_t best_preceding_node() const
Returns the index of the best preceding node.
Definition node.hpp:195