Re: Confusing Arraylist BinarySearch problem

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



We can even shorten up the issue. Let's say this is my array:

SAPArray.Add("04876497")
SAPArray.Add("48764205")
SAPArray.Add("48764212")
SAPArray.Add("48764229")
SAPArray.Add("48764236")
SAPArray.Add("48764243")
SAPArray.Add("48764250")
SAPArray.Add("48764267")
SAPArray.Add("48764274")
SAPArray.Add("48764281")
SAPArray.Add("48764298")
SAPArray.Add("48764304")
SAPArray.Add("48764311")
SAPArray.Add("48764328")
SAPArray.Add("48764335")
SAPArray.Add("48764342")
SAPArray.Add("48764359")
SAPArray.Add("48764366")
SAPArray.Add("48764373")
SAPArray.Add("48764380")
SAPArray.Add("48764397")
SAPArray.Add("11111111")
SAPArray.Add("22222222")
SAPArray.Add("33333333")
SAPArray.Add("44444444")
SAPArray.Add("55555555")
SAPArray.Add("66666666")
SAPArray.Add("77777777")

When I run this code directly after the array creation:
Dim index2 As Integer = SAPArray.BinarySearch("48764373", New
CaseInsensitiveComparer())
MsgBox(index2)

I get a negative value even though that item exists. For some reason
certain index values are more problematic them others. If I search for one
that's usual comes up good I get the proper index value.

But when I shorten my array to this:

SAPArray.Add("48764205")
SAPArray.Add("48764212")
SAPArray.Add("48764229")
SAPArray.Add("48764236")
SAPArray.Add("48764243")
SAPArray.Add("48764250")
SAPArray.Add("48764267")
SAPArray.Add("48764274")
SAPArray.Add("48764281")
SAPArray.Add("48764298")
SAPArray.Add("48764304")
SAPArray.Add("48764311")
SAPArray.Add("48764328")
SAPArray.Add("48764335")
SAPArray.Add("48764342")
SAPArray.Add("48764359")
SAPArray.Add("48764366")
SAPArray.Add("48764373")
SAPArray.Add("48764380")
SAPArray.Add("48764397")


I have no problems. The above code returns the proper index value.


.



Relevant Pages

  • Re: About Thread Completion Notify.
    ... This is the reason that i must keep track of the threads and they have to ... i remove it from the array. ... > (which you probably don't since you are servicing requests in separate ... you shouldn't have a need for waiting on events. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: please confirm something (jdbc)
    ... of its internal buffer so that will double the amount of memory that you need. ... That's the reason I wrote my own dynamic byte array ... Given all the memory re-allocation that goes on inside the ByteArrayOutputStream anyway, I'm not sure that one more allocation is all that much extra overhead. ... If I have two ways of coding something, and I know that one will definitely use less memory (or be quicker for whatever reason) then I will choose the one "better" one. ...
    (comp.lang.java.programmer)
  • Re: Help needed on Arrays
    ... What does the SQL Stored Procedure do? ... Is there a specific reason you want to create an extra ... be in an array or arraylist. ... The language is vb.net 2005. ...
    (microsoft.public.vsnet.general)
  • Re: what is the best datatype for..
    ... array that will be scanned searching for the index value, ... It also won't be flexible if the input data changes for any reason, since the implementation itself is so dependent on the input data. ... Calling the dictionary solution "inefficient" is just plain dumb; it might not be quite as fast as a straight array lookup, but it's not like it's a _slow_ design. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: array initialization: dimension list not constant
    ... CMUCL might complain that the dimension list is not constant, ... This has an impact on the performance of the array creation, ...
    (comp.lang.lisp)