LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Traditional data structures in LabVIEW

In my brief research preparing a small program to sort heirarchical data, I have found very little discussion about implementing and using traditional data structures (linked lists, trees, etc.) in LabVIEW. There are a few suggestions for implementing data structures using arrays of clusters, but the overall discourse on this topic is so thin as to make me suspect I am trying to put a square peg in round hole. Is it because data structures (beyond arrays) are just not required in most LabVIEW applications? Perhaps it is because the dataflow nature of LabVIEW makes implementation more of a nuisance then it is worth?

 

Most students first exposure to data structures and the algorithms used to manage them is within a control flow, object oriented language such as JAVA. Should one bite the bullet and learn LVOOP if one wants to use data structures with any regularity in LabVIEW?

 

0 Kudos
Message 1 of 3
(2,775 Views)

The main problem is that linked lists and trees require pointers to work (efficiently or at all) and LabVIEW doesn't have the concept of a pointer. Essentially, it takes care of all memory management behind the scenes. If you know what you're doing, however, you can build your code in such a way that it actually does pass the data around by using pointers.

 

If you search the LAVA forums, you should find implmentations both for a linked list and for a tree, both of them using LVOOP and some relatively new primitives which give you better memory control. As for your question, such structures do have their place, but most LabVIEW programmers probably don't need them (and probably don't even know they exist), as the problems they face can be solved using other methods.


___________________
Try to take over the world!
0 Kudos
Message 2 of 3
(2,745 Views)
I think the main probelem is that linked lists, trees etc. are implemented
as templates. So you can use them with whatever type you want, in
traditional languages.

In LabVIEW it is simply not possible to make your own VI's that adapt to any
type. NI can make functions that do this, but as a programmer, you can only
resort to polymorphic vi's. But even if you make a polymorphic VI for all
scalar types, what about arrays and clusters? You could make a general
implementation that stores any type as variant, but that isn't really
helping with the speed (which is probably the reason to make a list or tree
in the first place).

So, if you need a linked list implementation, you most likelly have to
rewrite a lot of it for the specific case, and since it's not that easy,
most people don't bother. It's not that hard either, so if you need to
program a linked list or tree, you should be able to make it (start by
searching a C implementation, and try to convert it to G) for your specific
case.

Regards,

Wiebe.


0 Kudos
Message 3 of 3
(2,713 Views)