Jump to content

Hash table equivalent


Recommended Posts

Not that I've seen.

You can build your own hash table system with arrays for storage. The actual hashing function is up to you, as are features like chaining and collision resolution.

You can also implement dictionaries, either with parallel arrays, or using the Variant and Variant Attribute types (which have an underlying red-black tree for speed).

Joe Z.

  • Like 1
Link to comment

Is there an equivalent of a hash table in LabView?

Not that I've seen.

You can build your own hash table system with arrays for storage. The actual hashing function is up to you, as are features like chaining and collision resolution.

You can also implement dictionaries, either with parallel arrays, or using the Variant and Variant Attribute types (which have an underlying red-black tree for speed).

There was a (long) thread on various hash (or map or dictionary) implementations started by Aristo Queue when he introduced an implementation using classes - various implementations were tried and benchmarked - this seems to be the relevant page in thr topic.

At the ime variant attribute seemed like it was the best (cespite those that should know about the internals of LabVIEW being surprised). I know AQ noted that his map with classes suffered from some specific bugs deep in the memory management interneals - I'm less clear if the performance has been fixed in 2009...

Link to comment

There was a (long) thread on various hash (or map or dictionary) implementations started by Aristo Queue when he introduced an implementation using classes - various implementations were tried and benchmarked - this seems to be the relevant page in thr topic.

At the ime variant attribute seemed like it was the best (cespite those that should know about the internals of LabVIEW being surprised). I know AQ noted that his map with classes suffered from some specific bugs deep in the memory management interneals - I'm less clear if the performance has been fixed in 2009...

Last time I looked into this about six months ago, the bug which had destroyed performance in the lvclass implementation had been fixed as of LV2009, but variant attributes still blew away the lvclass implementation in terms of performance, so we are still using that for hash tables. You'll want to keep your variant (which doesn't need to contain any data itself) in a functional global (aka LV2 global). You could also keep the variant in a data value reference or in a single-element queue to protect its integrity.

Link to comment

I don't know whether to ask this here or on the other thread, but are there any drawbacks about using Variant Attributes on real-time targets? Besides memory... And on that note, is there a better way of getting the number of the elements in the Variant than producing names/values arrays just to get the length?

Miha

Link to comment

I don't know whether to ask this here or on the other thread, but are there any drawbacks about using Variant Attributes on real-time targets? Besides memory... And on that note, is there a better way of getting the number of the elements in the Variant than producing names/values arrays just to get the length?

Miha

Can't answer the RT part of the question.

For your second question though, you could store the size of the table in the variant itself as it is not used for anything else in this scenario. Just remember to update the count whenever you add or remove a key/value pair.

-Scott

Link to comment

Can't answer the RT part of the question.

For your second question though, you could store the size of the table in the variant itself as it is not used for anything else in this scenario. Just remember to update the count whenever you add or remove a key/value pair.

-Scott

What an excellent suggestion :) Thanks.

Miha

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.