PR #3279 - Added some comments, harmonized a few names, removed unneeded spaces
This commit is contained in:
parent
23944b97db
commit
5bf5124366
@ -37,7 +37,7 @@ DecoderState::init(const Alphabet& alphabet,
|
|||||||
prefix_root_.reset(root);
|
prefix_root_.reset(root);
|
||||||
prefix_root_->timesteps = ×tep_tree_root_;
|
prefix_root_->timesteps = ×tep_tree_root_;
|
||||||
prefixes_.push_back(root);
|
prefixes_.push_back(root);
|
||||||
|
|
||||||
if (ext_scorer && (bool)(ext_scorer_->dictionary)) {
|
if (ext_scorer && (bool)(ext_scorer_->dictionary)) {
|
||||||
// no need for std::make_shared<>() since Copy() does 'new' behind the doors
|
// no need for std::make_shared<>() since Copy() does 'new' behind the doors
|
||||||
auto dict_ptr = std::shared_ptr<PathTrie::FstType>(ext_scorer->dictionary->Copy(true));
|
auto dict_ptr = std::shared_ptr<PathTrie::FstType>(ext_scorer->dictionary->Copy(true));
|
||||||
|
@ -24,11 +24,17 @@ struct TreeNode {
|
|||||||
TreeNode(TreeNode<DataT>* parent_, DataT const& data_): parent{parent_}, data{data_} {}
|
TreeNode(TreeNode<DataT>* parent_, DataT const& data_): parent{parent_}, data{data_} {}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/* Creates a new TreeNode<NodeDataT> with given data as a child to the given node.
|
||||||
|
* Returns a pointer to the created node. This pointer remains valid as long as the child is not destroyed.
|
||||||
|
*/
|
||||||
template<class NodeDataT, class ChildDataT>
|
template<class NodeDataT, class ChildDataT>
|
||||||
TreeNode<NodeDataT>* add_child(TreeNode<NodeDataT>* node, ChildDataT&& data_);
|
TreeNode<NodeDataT>* add_child(TreeNode<NodeDataT>* tree_node, ChildDataT&& data);
|
||||||
|
|
||||||
|
/* Returns the sequence of tree node's data from the given root (exclusive) to the given tree_node (inclusive).
|
||||||
|
* By default (if no root is provided), the full sequence from the root of the tree is returned.
|
||||||
|
*/
|
||||||
template<class DataT>
|
template<class DataT>
|
||||||
std::vector<DataT> get_history(TreeNode<DataT> const*, TreeNode<DataT> const* = nullptr);
|
std::vector<DataT> get_history(TreeNode<DataT> const* tree_node, TreeNode<DataT> const* root = nullptr);
|
||||||
|
|
||||||
using TimestepTreeNode = TreeNode<unsigned int>;
|
using TimestepTreeNode = TreeNode<unsigned int>;
|
||||||
|
|
||||||
@ -108,10 +114,10 @@ private:
|
|||||||
|
|
||||||
// TreeNode implementation
|
// TreeNode implementation
|
||||||
template<class NodeDataT, class ChildDataT>
|
template<class NodeDataT, class ChildDataT>
|
||||||
TreeNode<NodeDataT>* add_child(TreeNode<NodeDataT>* node, ChildDataT&& data_) {
|
TreeNode<NodeDataT>* add_child(TreeNode<NodeDataT>* tree_node, ChildDataT&& data) {
|
||||||
static thread_local godefv::memory::object_pool_t<TreeNode<NodeDataT>> tree_node_pool;
|
static thread_local godefv::memory::object_pool_t<TreeNode<NodeDataT>> tree_node_pool;
|
||||||
node->children.push_back(tree_node_pool.make_unique(node, std::forward<ChildDataT>(data_)));
|
tree_node->children.push_back(tree_node_pool.make_unique(tree_node, std::forward<ChildDataT>(data)));
|
||||||
return node->children.back().get();
|
return tree_node->children.back().get();
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class DataT>
|
template<class DataT>
|
||||||
|
Loading…
Reference in New Issue
Block a user