Re: Confusing Arraylist BinarySearch problem
- From: "Justin" <Justin@xxxxxxxxxx>
- Date: Tue, 5 Dec 2006 14:57:20 -0800
SAPArray.Sort()
Perfect! Thanks a bunch! I never knew that. I guess I've just been lucky
this whole time or something else was always sorting my data prior to
creation.
Am I to assume that once it hit where it thinks the value should be it stops
looking? If so then that's probably a huge speed increase in large array
scenarios.
Thanks again!
Thanks, Justin Emlay SAP Basis Administrator / Systems Department Maisto
International, Inc. 909-357-7988 ext.360 909-357-9958 fax JEmlay@xxxxxxxxxx
www.maisto.com
"Herfried K. Wagner [MVP]" <hirf-spam-me-here@xxxxxx> wrote in message
news:OeuPchKGHHA.2128@xxxxxxxxxxxxxxxxxxxxxxx
"Justin" <Justin@xxxxxxxxxx> schrieb:
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.
Items must be sorted in order to search an item using binary search. You
can call the arraylist's 'Sort' method to sort it.
--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>
.
- References:
- Confusing Arraylist BinarySearch problem
- From: Justin
- Re: Confusing Arraylist BinarySearch problem
- From: Justin
- Re: Confusing Arraylist BinarySearch problem
- From: Herfried K. Wagner [MVP]
- Confusing Arraylist BinarySearch problem
- Prev by Date: Using XPath Against A Node
- Next by Date: Re: No Response Redirect but something like Response Forward?
- Previous by thread: Re: Confusing Arraylist BinarySearch problem
- Next by thread: Reading a .DAT file with the Microsoft Text Driver
- Index(es):
Relevant Pages
|