473,405 Members | 2,415 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

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 3378
"Turbot" <ia*@tutorpro.com> wrote in news:1101135297.012615.66100
@z14g2000cwz.googlegroups.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********@rogers.com)
Please delete "REMOVE" from the e-mail address when replying.
http://members.ebay.com/aboutme/coolspot18/
Nov 21 '05 #2
Lucas Tam <RE********@rogers.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********@rogers.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********@rogers.com>
"Turbot" <ia*@tutorpro.com> wrote in news:1101135297.012615.66100
@z14g2000cwz.googlegroups.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********@rogers.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.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.

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**************@TK2MSFTNGP10.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********@rogers.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
by: Phil Powell | last post by:
/*-------------------------------------------------------------------------------------------------------------------------------- Parameters: $formField1: The name of the first array $formField2:...
4
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...
5
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};...
2
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...
2
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...
4
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...
5
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
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:...
0
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...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
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,...
0
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,...
0
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...

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.