473,775 Members | 2,186 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Compare Arrays

Hello,

Anyone know how to compare two byte arrays without going through each
item in the array. I actually want to compare two bitmap objects to see
if they both contain the same picture bit have been unable to do this.
I figured if I converted them to byte arrays there would be a simple
way of comparing them but I have had no luck.

Thanks in advance.

IAN

Nov 21 '05 #1
8 3404
"Turbot" <ia*@tutorpro.c om> wrote in news:1101135297 .012615.66100
@z14g2000cwz.go oglegroups.com:
Hello,

Anyone know how to compare two byte arrays without going through each
item in the array. I actually want to compare two bitmap objects to see
if they both contain the same picture bit have been unable to do this.
I figured if I converted them to byte arrays there would be a simple
way of comparing them but I have had no luck.

For your image objects, can you just do:

If ImageA is ImageB then
Msgbox("Image Objects Identical")
End If

Maybe the IS clause may work for your byte arrays too?
--
Lucas Tam (RE********@rog ers.com)
Please delete "REMOVE" from the e-mail address when replying.
http://members.ebay.com/aboutme/coolspot18/
Nov 21 '05 #2
Lucas Tam <RE********@rog ers.com> wrote in
news:Xn******** *************** ****@140.99.99. 130:
For your image objects, can you just do:

If ImageA is ImageB then
Msgbox("Image Objects Identical")
End If

Maybe the IS clause may work for your byte arrays too?

Oops - please disregard. The IS operator only does Reference comparison -
not value comparison.

--
Lucas Tam (RE********@rog ers.com)
Please delete "REMOVE" from the e-mail address when replying.
http://members.ebay.com/aboutme/coolspot18/
Nov 21 '05 #3
Lucas,

Sorry I break in an answer of you today again, however when I don't I think
it is not right as well.

Is compares if the addres of an object is the same as another object (and
than is the content as well the same).

Try this by instance
\\\
Public Class main
Public Shared Sub main()
Dim a As Image = Image.FromFile( "c:\my.jpg" )
Dim b As Image = a
Dim c As Image = Image.FromFile( "c:\my.jpg" )
If a Is b Then MessageBox.Show ("we are equal")
If Not c Is a Then MessageBox.Show ("We are not equal while we are")
End Sub
End Class
///

Sorry I felt I had to show you this,

Cor

"Lucas Tam" <RE********@rog ers.com>
"Turbot" <ia*@tutorpro.c om> wrote in news:1101135297 .012615.66100
@z14g2000cwz.go oglegroups.com:
Hello,

Anyone know how to compare two byte arrays without going through each
item in the array. I actually want to compare two bitmap objects to see
if they both contain the same picture bit have been unable to do this.
I figured if I converted them to byte arrays there would be a simple
way of comparing them but I have had no luck.

For your image objects, can you just do:

If ImageA is ImageB then
Msgbox("Image Objects Identical")
End If

Maybe the IS clause may work for your byte arrays too?
--
Lucas Tam (RE********@rog ers.com)
Please delete "REMOVE" from the e-mail address when replying.
http://members.ebay.com/aboutme/coolspot18/

Nov 21 '05 #4
Turbot,

What is wrong with looping through an array, how do you do that it is done
when there is a method, I think that it will be in a lot of cases even
faster.

See this all written in this message not tested and watch typos
\\\\
dim ImageIsUnequal as boolean
if arbyteA.length <> arbyteB.length then
ImageIsUnequal = true
Else
for i as integer = 0 to arrbyte.length -1
if arAbyte(i) <> arBbyte(i) then
ImageIsUnequal = true
exit for
Next
end if
///

I don't think that can much faster mostly it will be in the first comparing
already an unequal and when not than probably in the beginning of the for
loop.

I hope this helps?

Cor

"Turbot" <ia*@tutorpro.c om>

Hello,

Anyone know how to compare two byte arrays without going through each
item in the array. I actually want to compare two bitmap objects to see
if they both contain the same picture bit have been unable to do this.
I figured if I converted them to byte arrays there would be a simple
way of comparing them but I have had no luck.

Thanks in advance.

IAN

Nov 21 '05 #5
Lucas,

My message was already gone when I saw your own correction.

So ignore my message.

:-)

Cor
Nov 21 '05 #6
confusing typo
What is wrong with looping through an array, how do you do that it is done

What is wrong with looping through an array, how do you think that it is
done
Nov 21 '05 #7
"Cor Ligthert" <no************ @planet.nl> wrote in
news:O6******** ******@TK2MSFTN GP10.phx.gbl:
Sorry I break in an answer of you today again, however when I don't I
think it is not right as well.


Nah it's OK... I gave bad advice : )

--
Lucas Tam (RE********@rog ers.com)
Please delete "REMOVE" from the e-mail address when replying.
http://members.ebay.com/aboutme/coolspot18/
Nov 21 '05 #8
Hi,

Thanks for that. My main concern with comparing each byte in the array
was time but you are quite correct, most of the time, the length of the
byte array will be different so checking that first should give me a
negative result.

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 21 '05 #9

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

Similar topics

0
2713
by: Phil Powell | last post by:
/*-------------------------------------------------------------------------------------------------------------------------------- Parameters: $formField1: The name of the first array $formField2: The name of the second array $formField1CompareWith: String to use as my comparison basis for first array. Defaults to using $val unless it's 'key' $formField2CompareWith: String to use as my comparison basis for second array. Same default as...
4
5129
by: Gleep | last post by:
Hey Guys, I've got a table called Outcomes. With 3 columns and 15 rows 1st col 2nd col 3rdcol outcome date price There are 15 rows for each record, each row accounts for a different type of outcome I'm having trouble with MySQL date comparison. I'm looking for some kind of query that will compare the all date column and only give me the latest date. Then once I have it, ...
5
2996
by: Jim H | last post by:
I will have many 3 byte Byte arrays. Is there a way to compare the values without iterating through and comparing each element in the code? Example: byte lTest1 = new byte {0x1, 0x2, 0x3}; byte lTest2 = new byte {0x1, 0x2, 0x3}; byte lTest3 = new byte {0x1, 0x5, 0x3}; if(Comparer.Equals(lTest1, lTest2)) System.Diagnostics.Trace.WriteLine("Test1 and Test2 are the same", "Debug");
2
16366
by: nobs | last post by:
Hi I have two byte arrays (each with a length of 8 bytes) an I'd like to compare them if they are equal. The operator == shouldn't work because its not a basic Data Type so I used the method Equal, but it also isn't working. right know I use if(mykey.Length!= keytocheck.Length)
2
11347
by: Tom | last post by:
What's the best way to compare two byte arrays? Right now I am converting them to base64 strings and comparing those, as so: 'result1 and result2 are two existing byte arrays that have been loaded Dim data64_1 As String = System.Convert.ToBase64String(result1, 0, result1.Length) Dim data64_2 As String = System.Convert.ToBase64String(result2, 0, result2.Length) Debug.WriteLine(IIf(data64_1 = data64_2, "Equals", "NOT Equals"))
4
1993
by: Justin Emlay | last post by:
I have two lists. These can be in either table form or array. That is, my data is in a dataset which I can move to an array if need be. ListA is a master list and it contains all items. ListB contains the same items but not necessarily all the items. I need to know which items are missing. I remember messing with a compare array function but now I can't seem to find it anywhere. Ideas? I would rather NOT loop through each item in...
5
40103
by: Oleg Subachev | last post by:
Is there other way of comparing two byte arrays than iterating through the two and compare individual bytes ? Oleg Subachev
3
2897
by: =?Utf-8?B?UmljY2FyZG8=?= | last post by:
What is the best method to compare 2 array to knw if each element is equal? Now, i have to compare the datarow.itemarray of 2 datarows wich is equals in structure. I tried to write this routine: (OPTION STRICT MUST BE ON!!) Private Function ISArrayEquals(ByVal A As Array, ByVal B As Array) As Boolean For index As Integer = 0 To A.Length - 1 If A.GetValue(index) <B.GetValue(index) Then '<----Here is the error! Return False End If
0
38224
gits
by: gits | last post by:
This little article will show you how to optimize runtime performance when you need to compare two arrays (a quite common task). Have a close look at the entire article, and you will see the advantage of the final code snippet :) Let's assume we want to find out the element that is contained by both of the lists. var list1 = ; var list2 = ; for (var i in list1) { for (var j in list2) {
0
9625
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
10280
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
10115
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10056
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8944
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...
0
6721
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
5365
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5489
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3618
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.