|
Though if the array isn't sorted you may want to use qsort as well. Depending on the size of the array, and how often it is added to, it may very well be faster to run qsort when an element is added and then bsearch, than it is to use lookup. The nice thing about qsort/bsearch is that they can be used to sort/search arrays that are not trivially sortable, such as an array of pointers to data structures where you want to sort based on the contents of one of the subfields of the data structure. Or if you have a dynamically allocated array where the allocated length of the array is not as long as the declared length of the array. Also, I thought that %lookup implementing a binary search was a relatively recent update, so even if you could use %lookup it might not be faster than lookup if you were on an older release. Joe Lee >>> Jon.Paris@xxxxxxxxxxxxxx 01/13/2005 07:20:54 >>> >> 2) Use the C function qsort. Again many examples including the RPG Redbook. Oopppss - of course I meant bsearch. I'm _not_ a morning person! Jon Paris Partner400 www.Partner400.com
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2025 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].
Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.