Most efficient way to search an array for an element greater than a given value


#1

What is the most efficient way to search all or part of a very large text array for the first element greater than a given value? For example:

A = "123"
B is a very large sorted array
I = the first element in B which is greater than A, say "124567"

I will wish to conduct the search many hundreds of times for incremented values of A. Might using a data array be more efficient?


#2

Probably the best way available in Panorama is using the arrayfilter( function. It would be better if there was a superarraylookup( function, but there is no such beast.

If you can get the data in B into a database, then you could do a search, or a superlookup(. Either of those methods would probably be faster than using an array. Also, it sounds like the values in question are really numbers, and they could be stored as numbers in a database, which would be much faster yet.

Using a data array is not going to help you at all.

As general advice, arrays are intended to be lightweight structures, relatively small. If you are using the adjective “very large” then you should possibly think about using a database, since databases are designed with “very large” in mind.


#3

Good ideas - I can certainly try that. The interesting thing is that Panorama 6.0 is much, much faster than Panorama X when working on big arrays. The task I have involves an array of 135,000 elements with lots of arraychange( functions. Panorama 6.0 took 4 minutes, Panorama X took 51 minutes!!


#4

Panorama’s array code was definitely not designed with arrays of that size in mind – either Panorama 6 or Panorama X – I envisioned a few hundred elements at most.


#5

That’s interesting because Panorama 6.0 handles huge arrays with ease whereas Panorama X runs out of memory very quickly. I have a new iMac with 16GB of RAM and the task that Panorama 6.0 ran easily bombed out in Panorama X with memory overload.


#6

That could be but if so it is an accident. Panorama 6 was not designed for huge arrays, and I never tested it with huge arrays.


#7