PC Review


Reply
Thread Tools Rate Thread

Multi Dimensional Arrays

 
 
DazedAndConfused
Guest
Posts: n/a
 
      25th Jul 2005
Is the only way to searh for a value in a multi dimensional array is with a
loop?

Is a loop any less efficient then IndexOf in a single dimensional array?


 
Reply With Quote
 
 
 
 
Herfried K. Wagner [MVP]
Guest
Posts: n/a
 
      26th Jul 2005
"DazedAndConfused" <(E-Mail Removed)> schrieb:
> Is the only way to searh for a value in a multi dimensional array is with
> a loop?


Yes... When using jagged arrays you can use consecutive calls to
'Array.IndexOf' for the sub arrays.

> Is a loop any less efficient then IndexOf in a single dimensional array?


In general no. I suggest to read the "Remarks" section of the
'Array.IndexOf' method, which gives information about the implementation of
this method.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

 
Reply With Quote
 
DazedAndConfused
Guest
Posts: n/a
 
      26th Jul 2005
Sorry to be dense, from reading remarks it sounds like IndexOf searches the
complete array, then returns the index of the first occurence, there for the
loop is more efficient any ways. Is that what you were trying to convey with
your suggestion of reading remarks?


"Herfried K. Wagner [MVP]" <hirf-spam-me-(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> "DazedAndConfused" <(E-Mail Removed)> schrieb:
>> Is the only way to searh for a value in a multi dimensional array is with
>> a loop?

>
> Yes... When using jagged arrays you can use consecutive calls to
> 'Array.IndexOf' for the sub arrays.
>
>> Is a loop any less efficient then IndexOf in a single dimensional array?

>
> In general no. I suggest to read the "Remarks" section of the
> 'Array.IndexOf' method, which gives information about the implementation
> of this method.
>
> --
> M S Herfried K. Wagner
> M V P <URL:http://dotnet.mvps.org/>
> V B <URL:http://classicvb.org/petition/>



 
Reply With Quote
 
Cor Ligthert [MVP]
Guest
Posts: n/a
 
      26th Jul 2005
Dazed,

Are you developing for old PDA's.
Otherwise you are probably talking about fractions from milliseconds.

If you have performance problems, than I would look in more sufficient
places.

Cor


 
Reply With Quote
 
Herfried K. Wagner [MVP]
Guest
Posts: n/a
 
      26th Jul 2005
"DazedAndConfused" <(E-Mail Removed)> schrieb:
> Sorry to be dense, from reading remarks it sounds like IndexOf searches
> the complete array, then returns the index of the first occurence, there
> for the loop is more efficient any ways. Is that what you were trying to
> convey with your suggestion of reading remarks?


I didn't take a look at the implementation, but I doubt that this is the
case. Typically linear search will stop when the first occurance is found.
The runtime function is in O(n) for a list containing n items.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Multi-dimensional arrays Amien Crombie Microsoft C# .NET 2 5th Jun 2009 03:02 PM
More Multi-Dimensional Arrays =?Utf-8?B?Q2xheW1hbg==?= Microsoft Excel Programming 1 31st Jul 2007 06:18 PM
More Multi-Dimensional Arrays =?Utf-8?B?Q2xheW1hbg==?= Microsoft Excel Programming 0 31st Jul 2007 06:10 PM
Multi-dimensional arrays gti_jobert Microsoft Excel Programming 6 6th Feb 2006 05:45 AM
Arrays, multi-dimensional Jim Microsoft Access VBA Modules 5 7th Jul 2004 01:48 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 11:28 PM.