Götz Becker Posted July 15, 2011 Report Share Posted July 15, 2011 Is the list of names/attributes returned by "get variant attribute" without a name connected always (guaranteed) sorted? It is sorted at all my tests but is this a feature or just a coincidence and might change if the underlying algorithms change. Since this isn't documented, it could change without notice in a new LV version!?! Quote Link to comment
Phillip Brooks Posted July 15, 2011 Report Share Posted July 15, 2011 Is the list of names/attributes returned by "get variant attribute" without a name connected always (guaranteed) sorted? It is sorted at all my tests but is this a feature or just a coincidence and might change if the underlying algorithms change. Since this isn't documented, it could change without notice in a new LV version!?! It isn't documented, but I think the implementation is a red/black tree to allow for fast searches. This requires the list to be rebalanced (resorted) whenever an item is added, so it is stored sorted (by attribute name). If the function returns a list of items when the name is left blank, it makes sense that the list would always be returned sorted. NI could certainly change this behavior, but I'd bet that this would break a bunch of NI code. See the dark side: Darren's Weekly Nugget 10/09/2006 http://forums.ni.com/t5/LabVIEW/Darren-s-Weekly-Nugget-10-09-2006/td-p/425269 Quote Link to comment
crelf Posted July 15, 2011 Report Share Posted July 15, 2011 If you're worried about an undocumented feature going away, why not just add a sort after the read? Quote Link to comment
Popular Post Aristos Queue Posted July 17, 2011 Popular Post Report Share Posted July 17, 2011 The list should always be sorted. I have filed CAR 308287 to update the documentation accordingly. 3 Quote Link to comment
silmaril Posted July 18, 2011 Report Share Posted July 18, 2011 If you're worried about an undocumented feature going away, why not just add a sort after the read? If you are worried about performance and memory usage, why add an unneeded sort? I don't know which sorting algorithm "Sort 1D Array" uses, but I think I've heard it's Quicksort. This algorithm needs an especially large number of iterations, if the input array is already sorted. We wouldn't want to waste CPU time and memory on sorting a few thousand strings that are already in the correct order, just because of incomplete documentation. AQ: Thank you very much for your reply! You are really succeeding in optimizing the quotient helpfullness / number of characters in answer. Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.