Tree structure of structs

I want to create tree structure of structs, but my struct A cant have TArray<A> type parameter. It says ‘struct recursion via arrays is not supported’. Kinda idiotism but, anyway, how to beat it? I can’t do this in blueprints and C++ either.

This is more a general Data organizing question. The fist thing I found on stackoverflow was to use linked lists. Tree data structure in C# - Stack Overflow Basically you make an array of your data struct, that holds the Data you want and an Integer in it, that holds the array index to it’s parent. If you need to find children, you would need to add an array of integer that holds the corresponding indices. To get and set the actual data, you would need to programm a manager yourself.

That’s how I’d do it, maybe you find something more useful if you search for data management in folder structures.

Btw. it’s good that Unreal prevents you form circular data structs. These things are definitions and no actual data. If you imagine that you could do that, your definition would be: your data struct ‘A’ contains a data struct ‘A’ wich would contain by definition the data struct ‘A’… and so on.

1 Like

By default my array is empty, so infinite recursion wouldn’t happen. It would be better if it warned me, and did not forbid it.

3 Likes