Re: Using Array.FindAll

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



Jerry Spence1 wrote:
I'm using VB2005

I have an array of some 500,000 items which are of the form 080715_175327_312.jpg. These are camera frames of the form YYMMDD_HHmmss_ms.jpg

I want to create another array which contains all the items which are (> 080715_1730) and (< 080716_0810)

What is the fastest way? I've found FindAll and IndexOf, but I can't work out how to do it.

Thanks

-Jerry


Fortunately you have used an ISO 8601 like date format, which means that the strings can be compared without having to parse each single value into a DateTime value.

If the array is sorted, you can use the Array.BinarySearch method to find the first and the last item. That would be very much faster than looping through all the items.

If the array is not sorted, you have to loop. If you want to use the FindAll method for that, you need a method like this to do the comparison:

Function Compare(value As String) As Boolean
Return value > "080715_1730" And value < "080716_0810"
End Function

--
Göran Andersson
_____
http://www.guffa.com
.



Relevant Pages

  • Re: K&R2 Secition 5.9 - major blunders
    ... Each element of b doesn't point to a 20 element array of int. ... This mistake is crucial because ... my explanation is really the qualities of something else: ... > The use of the array of pointers is to store the strings. ...
    (comp.lang.c)
  • Re: K&R2 Secition 5.9 - major blunders
    ... Each element of b doesn't point to a 20 element array of int. ... This mistake is crucial because ... my explanation is really the qualities of something else: ... > The use of the array of pointers is to store the strings. ...
    (comp.lang.c)
  • Re: Returning array of strings through callback from unmanaged to
    ... Is the array of strings a jagged array or fixed length array? ... It is imperative that I am able to return the array of strings from the ... I have control over how many strings I want the unmanaged code to return ... What I want to accomplish is to pass a callback function to unmanaged ...
    (microsoft.public.dotnet.framework.compactframework)
  • Re: attempting to return values from array from w/in a function
    ... What I get is an array w/ only the most recent array entry. ... I am new to PHP & do not have formal scripting ... you end up comparing strings, but the test you mean probably is simply: ... case 1: {codeblock} ...
    (comp.lang.php)
  • Re: K&R2 Secition 5.9 - major blunders
    ... Would changing 'point to a' to 'point into a' twenty element array be ... > arrays of pointers is to store character strings of diverse ... comparison between what was really happening (arrays of pointers to ... pointer to a string(this probably would confuse beginners)" and ...
    (comp.lang.c)