Array of structure

Hello,

Is there a way to build an array of structure in a plugin and return it to Xojo. The structure is already declared in a.h file. If yes, some hints on how to do it would be appreciated.

Today I return a MemoryBlock and map datas with a structure declared in Xojo. It works but I’d like to do something more ‘fun’

Thanks in advance

Can’t help with plugins, but I’d like to warn about a confirmed bug in Xojo, #65039.
“Bug in Raspberry Pi compiler if size of Structure in array is over 20 bytes.Raspberry Pi structures”.

I would say save your self the drama and return array of Class instances rather than array of struct.

A class instance in the end stores struct anyhow.

2 Likes

This was my first idea, but as the array returned by the plugin may have 500k or more elements, I thought without testing it that it would take a long time. The array contains the state (from → to) of all the connections in a neural network, as well as the weight of each link.

I’ve just done a quick test in pure Xojo and it’s relatively fast. Creating an array of 500k instances of a class with three properties takes 220ms on my Intel iMac :thinking: I’ll give a try from the plugin.

Actually, if your returning them all at once…

Then you could return just one instance of a class which has all the data. That then has Array like interface on it to read the data in whatever way you want. Thats probably by far most efficient solution (if your returning it all at once)

As usual, good advice. Thanks Björn.