parent function doesn't work
parent
804378f2a6
commit
a43922589f
|
@ -1,5 +1,5 @@
|
||||||
cmake_minimum_required(VERSION 3.25)
|
cmake_minimum_required(VERSION 3.25)
|
||||||
project(blt-gp VERSION 0.0.141)
|
project(blt-gp VERSION 0.0.142)
|
||||||
|
|
||||||
include(CTest)
|
include(CTest)
|
||||||
|
|
||||||
|
|
16
src/tree.cpp
16
src/tree.cpp
|
@ -225,24 +225,22 @@ namespace blt::gp
|
||||||
return index;
|
return index;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// this function doesn't work!
|
||||||
blt::ptrdiff_t tree_t::find_parent(gp_program& program, blt::ptrdiff_t index) const
|
blt::ptrdiff_t tree_t::find_parent(gp_program& program, blt::ptrdiff_t index) const
|
||||||
|
{
|
||||||
|
blt::i64 children_left = 0;
|
||||||
|
do
|
||||||
{
|
{
|
||||||
if (index == 0)
|
if (index == 0)
|
||||||
return 0;
|
return 0;
|
||||||
blt::i64 children_left = 1;
|
|
||||||
// move to the left
|
|
||||||
--index;
|
|
||||||
do
|
|
||||||
{
|
|
||||||
const auto& type = program.get_operator_info(operations[index].id);
|
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)
|
if (type.argc.argc > 0)
|
||||||
children_left -= type.argc.argc;
|
children_left -= type.argc.argc;
|
||||||
|
children_left++;
|
||||||
if (children_left <= 0)
|
if (children_left <= 0)
|
||||||
break;
|
break;
|
||||||
children_left++;
|
--index;
|
||||||
} while (children_left > 0);
|
} while (true);
|
||||||
|
|
||||||
return index;
|
return index;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue