Porting some python code to LabVIEW and I run across the python set(). Is there a better way of representing this in LabVIEW other than with a variant or array?
2 Answers
The closest would be to use variant attributes.
You use a "dummy" variant to store key/value pairs. The Variant Set Attribute function prevents duplicates (overwrites existing with output indicating replaced) and the Get function will return all key/value pairs if no key value is specified.
The underlying functions use a red-black tree, making lookups very fast for large datasets.
http://forums.ni.com/t5/LabVIEW/Darren-s-Weekly-Nugget-10-09-2006/m-p/425269

- 643
- 4
- 8
-
Hadn't thought of using them that way. I was using an array of variants, but that's clearly more efficient, thanks. – Bondolin Sep 23 '14 at 12:36
As I recall LabView don't include analog of set() from box. Therefore you must create VI for delete duplicate values from Array. I hope below two links will help for you.
Remove duplicate values in an Array Delete, Collapse, Array Duplicate Elements
Furthermore you can take some HashSet realisation (one, two, three) and call it from LabView.

- 4,376
- 1
- 21
- 25
-
I'm afraid I can't call a C module -- needs to be pure LV. I think I will just implement my own class. May put it up on the NI forums later. Thanks, though. – Bondolin Sep 15 '14 at 14:18