silly
parent
6e45ea3d6d
commit
804378f2a6
|
@ -1,5 +1,5 @@
|
|||
cmake_minimum_required(VERSION 3.25)
|
||||
project(blt-gp VERSION 0.0.140)
|
||||
project(blt-gp VERSION 0.0.141)
|
||||
|
||||
include(CTest)
|
||||
|
||||
|
|
|
@ -60,31 +60,6 @@ namespace blt::gp
|
|||
{
|
||||
using iter_type = std::vector<op_container_t>::const_iterator;
|
||||
public:
|
||||
tree_t(): reference_counter(new std::atomic_int64_t(1))
|
||||
{}
|
||||
|
||||
tree_t(const tree_t& copy): operations(copy.operations), values(copy.values), reference_counter(copy.reference_counter)
|
||||
{
|
||||
reference_counter->operator++();
|
||||
}
|
||||
|
||||
tree_t(tree_t&& move) noexcept:
|
||||
operations(std::move(move.operations)), values(std::move(move.values)), reference_counter(move.reference_counter)
|
||||
{
|
||||
move.reference_counter = nullptr;
|
||||
}
|
||||
|
||||
tree_t& operator=(const tree_t& copy) = delete;
|
||||
|
||||
tree_t& operator=(tree_t&& move) noexcept
|
||||
{
|
||||
operations = std::exchange(operations, std::move(move.operations));
|
||||
values = std::exchange(values, std::move(move.values));
|
||||
reference_counter = std::exchange(reference_counter, move.reference_counter);
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
[[nodiscard]] inline std::vector<op_container_t>& get_operations()
|
||||
{
|
||||
return operations;
|
||||
|
@ -142,7 +117,8 @@ namespace blt::gp
|
|||
|
||||
bool check(gp_program& program, void* context) const;
|
||||
|
||||
blt::ptrdiff_t find_endpoint(blt::gp::gp_program& program, blt::ptrdiff_t start);
|
||||
blt::ptrdiff_t find_endpoint(blt::gp::gp_program& program, blt::ptrdiff_t start) const;
|
||||
blt::ptrdiff_t find_parent(blt::gp::gp_program& program, blt::ptrdiff_t start) const;
|
||||
|
||||
// valid for [begin, end)
|
||||
static blt::size_t total_value_bytes(iter_type begin, iter_type end)
|
||||
|
@ -173,16 +149,6 @@ namespace blt::gp
|
|||
}
|
||||
|
||||
void drop(gp_program& program);
|
||||
|
||||
~tree_t()
|
||||
{
|
||||
if (reference_counter == nullptr)
|
||||
return;
|
||||
reference_counter->operator--();
|
||||
if (*reference_counter == 0)
|
||||
delete reference_counter;
|
||||
}
|
||||
|
||||
private:
|
||||
std::vector<op_container_t> operations;
|
||||
blt::gp::stack_allocator values;
|
||||
|
|
2
lib/blt
2
lib/blt
|
@ -1 +1 @@
|
|||
Subproject commit 644f42684320edc95f9fd5fc3b203bda3c4e6633
|
||||
Subproject commit 6f06647a21f7f29e99ef8e45e1d3c08db0b46038
|
24
src/tree.cpp
24
src/tree.cpp
|
@ -207,7 +207,7 @@ namespace blt::gp
|
|||
return depth;
|
||||
}
|
||||
|
||||
blt::ptrdiff_t tree_t::find_endpoint(gp_program& program, blt::ptrdiff_t index)
|
||||
blt::ptrdiff_t tree_t::find_endpoint(gp_program& program, blt::ptrdiff_t index) const
|
||||
{
|
||||
blt::i64 children_left = 0;
|
||||
|
||||
|
@ -225,6 +225,28 @@ namespace blt::gp
|
|||
return index;
|
||||
}
|
||||
|
||||
blt::ptrdiff_t tree_t::find_parent(gp_program& program, blt::ptrdiff_t index) const
|
||||
{
|
||||
if (index == 0)
|
||||
return 0;
|
||||
blt::i64 children_left = 1;
|
||||
// move to the left
|
||||
--index;
|
||||
do
|
||||
{
|
||||
const auto& type = program.get_operator_info(operations[index].id);
|
||||
BLT_TRACE_STREAM << "Operating on index " << index << " with children left: " << children_left << " and argc = " << type.argc.argc << "\n";
|
||||
--index;
|
||||
if (type.argc.argc > 0)
|
||||
children_left -= type.argc.argc;
|
||||
if (children_left <= 0)
|
||||
break;
|
||||
children_left++;
|
||||
} while (children_left > 0);
|
||||
|
||||
return index;
|
||||
}
|
||||
|
||||
bool tree_t::check(gp_program& program, void* context) const
|
||||
{
|
||||
static thread_local detail::bitmask_t bitfield;
|
||||
|
|
Loading…
Reference in New Issue