12-16-2014 10:16 AM
There was a recent Webinar about Variants and its many uses. One of the uses it talked about was quickyly searching through an Array for all elements that equal X. Granted, I could easily just throw down a For Loop and have a conditional logic, "Does X = Array Element." But, the point of what I want to do is not have to parse through an Array of element size 700+. The webinar mentioned that Variants can do this quicker. Or is there another way to do this quicker than simple parse through entire array? Suggestions would be greatly appreciated.
12-16-2014 10:45 AM
If you are looking for 1 specific element, then you just need a shift register with the count. If you are looking for multiple items, then use the Variant.
12-16-2014 10:46 AM
For 700 elements, I doubt you will notice any difference between the methods mentioned.
12-16-2014 10:54 AM
Yes looking for multiple. And when I say 700, it's really just a guess. That's what I'm working with now, could be more. Since the Array size is unknown, that's why I was thinking Variant.
So with a Variant, what does one do? Change data to Variant and then search for value?
12-16-2014 10:58 AM - edited 12-16-2014 11:01 AM
@DailyDose wrote:
There was a recent Webinar about Variants and its many uses. .... Or is there another way to do this quicker than simple parse through entire array? Suggestions would be greatly appreciated.
Actually the "Data" does not become the Varient. The Data Elements become "Attributes" of the Varient (The Varient value is often "Void" in these uses)
Now we are getting into esoteric areas about data theory
I won't go there since others have much better mastery of that arcane knowledge than I. Simple entery level stuff can be found here and expanded a bit here
Varients use a "Red-Black" structure. And of Course, there must be a better and quicker way! Just none of those geeky CS type nerds have discovered it yet to the best of my knowledge
12-16-2014 11:03 AM
http://forums.ni.com/t5/LabVIEW/Darren-s-Weekly-Nugget-10-09-2006/td-p/425269
What type of data are you searching for?
12-16-2014 11:10 AM
aputman wrote:
What type of data are you searching for?
That is a very good point. The variant attribute name must be a string. So you may have to convert your data elements to a string to properly use the variant. Would have to do some benchmarks if that negates the search advantages you gain with the variant.
12-16-2014 11:13 AM - edited 12-16-2014 11:13 AM
So the question here then becomes, do I change my Array of data to Variant data? I've attached the SubVI. It's in 2011 which is why I'm not using conditional indexing. And Jeff, all I got to say is...
12-16-2014 11:20 AM
Since you don't actually have names to go with your data and you are dealing with numbers, I recommend to just stick with what you have.
12-16-2014 11:44 AM
After seeing your code.... no, this is not a place I would use a Varient. (I did miss the webcast so I'll leave comments about that to others)
A Varient can be used for effiecntly retrieveing data (of any types as an attribute) from a unique key as a string. Think "Ubber fast " Lookup Table.
In your code you want to retrieve Data by Value by searching data value.
Time to upgrade the LabVIEW version to get those nice conditional tunnels! and move that comparison outside the loop! (Hint index on the array of booleans out of "Equals")