PC Review


Reply
Thread Tools Rate Thread

Compare Arrays

 
 
Turbot
Guest
Posts: n/a
 
      22nd Nov 2004
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

 
Reply With Quote
 
 
 
 
Lucas Tam
Guest
Posts: n/a
 
      22nd Nov 2004
"Turbot" <(E-Mail Removed)> 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 ((E-Mail Removed))
Please delete "REMOVE" from the e-mail address when replying.
http://members.ebay.com/aboutme/coolspot18/
 
Reply With Quote
 
Lucas Tam
Guest
Posts: n/a
 
      22nd Nov 2004
Lucas Tam <(E-Mail Removed)> wrote in
news:Xns95A97EFA21BF8nntprogerscom@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 ((E-Mail Removed))
Please delete "REMOVE" from the e-mail address when replying.
http://members.ebay.com/aboutme/coolspot18/
 
Reply With Quote
 
Cor Ligthert
Guest
Posts: n/a
 
      22nd Nov 2004
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" <(E-Mail Removed)>

> "Turbot" <(E-Mail Removed)> 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 ((E-Mail Removed))
> Please delete "REMOVE" from the e-mail address when replying.
> http://members.ebay.com/aboutme/coolspot18/



 
Reply With Quote
 
Cor Ligthert
Guest
Posts: n/a
 
      22nd Nov 2004
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" <(E-Mail Removed)>


> 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
>



 
Reply With Quote
 
Cor Ligthert
Guest
Posts: n/a
 
      22nd Nov 2004
Lucas,

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

So ignore my message.

:-)

Cor


 
Reply With Quote
 
Cor Ligthert
Guest
Posts: n/a
 
      22nd Nov 2004
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


 
Reply With Quote
 
Lucas Tam
Guest
Posts: n/a
 
      22nd Nov 2004
"Cor Ligthert" <(E-Mail Removed)> wrote in
news:O6Am#(E-Mail Removed):

> 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 ((E-Mail Removed))
Please delete "REMOVE" from the e-mail address when replying.
http://members.ebay.com/aboutme/coolspot18/
 
Reply With Quote
 
Ian Kevan
Guest
Posts: n/a
 
      23rd Nov 2004
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!
 
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
Compare two arrays Greg Snidow Microsoft Excel Programming 5 1st Dec 2009 03:34 AM
Compare arrays mavxob Microsoft Excel Worksheet Functions 5 6th Mar 2008 10:55 PM
Compare arrays =?Utf-8?B?eW91bmdzdGVy?= Microsoft Excel Worksheet Functions 3 31st Jul 2007 04:36 PM
how to compare two arrays? Ofer Microsoft Excel Programming 1 7th Dec 2006 07:10 PM
How to compare 2 int arrays? yaya via DotNetMonster.com Microsoft C# .NET 6 16th Jan 2005 06:18 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 09:03 AM.