Jump to content



Photo

Extended binary search, ArrayInsert, and other array UDFs


  • Please log in to reply
No replies to this topic

#1 GaryC

GaryC

    Seeker

  • Active Members
  • 17 posts

Posted 28 February 2012 - 04:04 AM

This UDF contains modifications of functions in Array.au3 as well as a couple of other functions that ended up in the file I use in a couple of my projects. I replaced the "_" prefix with "my" to avoid name collisions. There is also commented-out test code for two of the functions. I hope the tests can serve as examples.
MyArrayInsert - _ArrayInsert modified to allow insertion of an array into another array, also appending to an array.
MyArrayBinarySearch - _ArrayBinarySearch modified to return the index at which to insert a not-found item, also to search 2d arrays.
MyArrayAdd - wrapper for _ArrayAdd that creates the array if the specified variable isn't an array. This could be added to _ArrayAdd but the wrapper was a quick way to implement it before I pulled it out into a library.
MyArrayPop - _ArrayPop modified to pop multiple items. This might not be useful very often.
MyArrayBinarySearch and MyArrayInsert should be backward compatible with the functions they replace. I kept and modified the header blocks (I hope) appropriately. MyArrayAdd, MyArrayPop, Display2d, and the test functions don't have standard header comment blocks.
Display2d returns a string containing a display of a 2d array. I use it for debugging in some of my code, but it may not be of much interest to anyone else. It certainly needs to be renamed, which I haven't done so I don't have to change my code base :-).

The functions are in attached file myarray_d.au3. Attached file _ArrayBinarySearch.au3 is a modified example file for MyArrayBinarySearch.

Enjoy!

GaryC

Attached Files










0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users