473,785 Members | 2,829 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Comparing 2 arrays, what's the fastest way ?

Hi! I am trying to determine if the DataRow of one dataset contains the same
data as the DataRow of another. I figured I can extract ItemArray's from each
dataset and then compare them.

1) Is this the fastest way? I will have to loop through thousands of rows
for what I am doing.

2) How can I compare arrays for Value Equality ? I do not think array's
..Equal method does Value Equality check. Based on what I understood, it does
Reference Equality check. Am I right ?
Any input is greatly appreciated,

Nov 16 '05 #1
2 6227
Mike <Mi**@discussio ns.microsoft.co m> wrote:
Hi! I am trying to determine if the DataRow of one dataset contains the same
data as the DataRow of another. I figured I can extract ItemArray's from each
dataset and then compare them.

1) Is this the fastest way? I will have to loop through thousands of rows
for what I am doing.
I don't know whether it's worth using ItemArray rather than just
accessing each column in turn - you should benchmark both cases.
2) How can I compare arrays for Value Equality ? I do not think array's
.Equal method does Value Equality check. Based on what I understood, it does
Reference Equality check. Am I right ?


Yes.

--
Jon Skeet - <sk***@pobox.co m>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 16 '05 #2
Mike <Mi**@discussio ns.microsoft.co m> wrote:
Hi! I am trying to determine if the DataRow of one dataset contains the same
data as the DataRow of another. I figured I can extract ItemArray's from each
dataset and then compare them.

1) Is this the fastest way? I will have to loop through thousands of rows
for what I am doing.
I don't know whether it's worth using ItemArray rather than just
accessing each column in turn - you should benchmark both cases.
2) How can I compare arrays for Value Equality ? I do not think array's
.Equal method does Value Equality check. Based on what I understood, it does
Reference Equality check. Am I right ?


Yes.

--
Jon Skeet - <sk***@pobox.co m>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 16 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
461
by: Peter | last post by:
Hi how can I compare two byte arrays in VB.NET Thank Peter
1
495
by: Iain | last post by:
Hi Hopefully I am missing something really simple with this question, but here goes. I have two Bitarrays that I would like to compare. At the moment, I am XORing one with the other and checking to see if the result has any 1s in it (if so, the arrays are different). This seems to be faster than comparing each bit of the two original arrays one at a time. But I still have to iterate over each element of the array, and I'd like to
12
885
by: Elijah Bailey | last post by:
I have two char arrays of size k. I want to know which one is bigger (exactly like for instance I compare two ints/longs/etc.). What is the fastest way to do this? k <= 10 usually for my application. I tried bcmp / a loop for comparison, but it seems they are very slow compared to comparing longs...Any ideas? I tried splitting the array into longs and comparing, but then I face the high endian/low endian problem on some machines.
4
10538
by: agent349 | last post by:
First off, I know arrays can't be compared directly (ie: if (arrary1 == array2)). However, I've been trying to compare two arrays using pointers with no success. Basically, I want to take three sets of character strings from the user. Then I want to run through each element and compare the two strings. If they match I print they match... I'm having a bit of trouble with the actual loop through each array using the pointers and comparing...
1
7576
by: mdub317 | last post by:
I'm totally new to programming and I am wondering; when would be a good time to use an array or an indexer? I want to know what types of applications would make good use of arrays or indexers. There seems to be other ways of doing the jobs of the two and less confusing. The books I read don't provide good examples of situations when I would need an array or indexer. I don't really need a definition of them as I already have that. I...
0
283
by: Mike | last post by:
Hi! I am trying to determine if the DataRow of one dataset contains the same data as the DataRow of another. I figured I can extract ItemArray's from each dataset and then compare them. 1) Is this the fastest way? I will have to loop through thousands of rows for what I am doing. 2) How can I compare arrays for Value Equality ? I do not think array's ..Equal method does Value Equality check. Based on what I understood, it does...
3
21371
by: Lance | last post by:
What is the fastest way to determine if two arrays that contain ValueTypes are equal? For example, lets say I have the following: Dim pt1 as New Drawing.Point(1, 2) Dim pt2 as New Drawing.Point(2, 3) Dim pt3 as New Drawing.Point(3, 4) Dim pt4 as New Drawing.Point(4, 5) Dim A() as Drawing.Point = {pt1, pt2, pt3}
1
2246
by: Donald Grove | last post by:
If I have two arrays, what is a good paradigm for comparing what is in them, to determine what elements they share, or don't share? Specifically, each array could potentially contain the integers 1 to 9, but probably not all 9 integers. MyArray1 = 1,2,3,5,6,7,8 MyArray2 = 1,4,6,7 I would need the answers to be arrays too:
1
7696
by: psmahesh | last post by:
Hi folks, I am comparing two arrays and removing matches from the second array from the first array. Can someone take a look at this code below and mention if this is okay and perhaps if there is a better way to achieve it for(i=0;i<arrayA.length;i++){ for(j=0;j<arrayB.length;j++){ if(arrayA==arrayB)
0
9645
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10327
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8973
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7499
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6740
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5511
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4053
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3647
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2879
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.