Jump to content

Extended binary search, ArrayInsert, and other array UDFs

Recommended Posts

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.





Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    No registered users viewing this page.

  • Create New...