01-03-2022 11:47 PM
I wondered if there was a way to use the new LabVIEW MAP functions to find "near", but not exact, matches. In other words, if an exact match is not found, is there a way to return the nearest value that is above and below the key being searched for?
I'm guessing that exporting the map to an array for each "find" operation would not be efficient.
It seems like the answer might be no and that I should consider an using an array of a custom cluster where I write, insert, remove, and find VIs to keep the items in the array sorted and to find the nearest key.
Thoughts?
Thanks
Jim
Solved! Go to Solution.
01-04-2022 06:16 AM
@JimASim wrote:Thoughts?
Thanks
Jim
The answer is indeed 'no'.
@JimASim wrote:
I'm guessing that exporting the map to an array for each "find" operation would not be efficient.
You might be wrong about that.
Iterating all elements of a map should be just as fast as looping over all items in an array.
Of course if you have an ordered array, that would be faster iff you can take advantage of the ordering. That would take some work though. The new .vims in LV21 would search for exact matches, not nearest.
01-04-2022 10:46 AM
.Thanks. I was intending on keeping the array ordered at all times by inserting new items in their appropriate place. Then I would binary search the array for the item I was looking for.
Jim