If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.
Announcement
Collapse
No announcement yet.
Using the binary search function on structured data.
I wrote this to create a simple array that can be searched. It returns a new array by reference to structure member values so it uses less memory and in theory should be faster than making a copy of the data. Maybe someone else has a better idea.
Code:
<MvFUNCTION NAME = "SimpleArrayfromStructure" PARAMETERS = "structure var, member, simple var">
<MvCOMMENT>
Extract a member from a structured array and return a simple array by reference
Returns the number if items in the arrays
</MvCOMMENT>
<MvFOREACH ITERATOR = "l.item" ARRAY = "l.structure" INDEX = "l.pos">
<MvREFERENCE NAME = "{ 'l.simple[' $ l.pos $ ']' }" VARIABLE = "{ 'l.item:' $ l.member }">
</MvFOREACH>
<MvFUNCTIONRETURN VALUE = "{ l.pos - 1 }">
</MvFUNCTION>
Ray Yates
"If I have seen further, it is by standing on the shoulders of giants."
--- Sir Isaac Newton
Comment