You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

33 lines
846 B

#include "blobtree.hpp"
EXTERN_C_BEGIN
8 months ago
blobtree_t::iterator blobtree_t::push_primitive_node(const primitive *primitive_ptr)
{
auto iter = nodes.emplace();
iter->node_data.emplace<primitive *>(const_cast<primitive *>(primitive_ptr));
8 months ago
return iter;
}
void blobtree_t::pop_node(blobtree_t::iterator node) { nodes.erase(node); }
blobtree_t::iterator blobtree_t::push_operation_node(internal::eNodeOperation op, iterator lhs, iterator rhs)
{
if (!lhs->is_parent_null() || !rhs->is_parent_null()) {
throw std::runtime_error("Cannot set operation node with non-null parent.");
}
auto iter = nodes.emplace();
iter->node_data.emplace<internal::eNodeOperation>(op);
iter->left_child = &*lhs;
iter->right_child = &*rhs;
lhs->parent = &*iter;
rhs->parent = &*iter;
return iter;
}
EXTERN_C_END