Check if array contains array

  • (2 Pages)
  • +
  • 1
  • 2

19 Replies - 3258 Views - Last Post: 14 August 2010 - 11:50 AM Rate Topic: -----

#16 pbl  Icon User is offline

  • There is nothing you can't do with a JTable
  • member icon

Reputation: 8347
  • View blog
  • Posts: 31,913
  • Joined: 06-March 08

Re: Check if array contains array

Posted 14 August 2010 - 09:51 AM

First check if the size of the files are equal
If it is the case just use 2 BufferedInputStream and compare byte per byte the bytes read from the 2 files. No need to know if they are text files or image files or executable files or ...
Was This Post Helpful? 0
  • +
  • -

#17 Guest_nub*


Reputation:

Re: Check if array contains array

Posted 14 August 2010 - 10:00 AM

View Postpbl, on 14 August 2010 - 08:51 AM, said:

First check if the size of the files are equal
If it is the case just use 2 BufferedInputStream and compare byte per byte the bytes read from the 2 files. No need to know if they are text files or image files or executable files or ...

OK that makes sense. But the file sizes would never be equal since they are not the same size picture. and why doesn't my code work?
Was This Post Helpful? 0

#18 pbl  Icon User is offline

  • There is nothing you can't do with a JTable
  • member icon

Reputation: 8347
  • View blog
  • Posts: 31,913
  • Joined: 06-March 08

Re: Check if array contains array

Posted 14 August 2010 - 10:23 AM

We start by having a topic on how to verify if an array is a subarray of another one
Now we are comparing 2 images to see if one is a cropped image of the other one ?

This is a lot more complicated than you think.
The easiest way would be to crop the largest one to the size of the smallest one and then compare all the bytes accepting an error ratio of something like 5%
Was This Post Helpful? 0
  • +
  • -

#19 macosxnerd101  Icon User is online

  • Self-Trained Economist
  • member icon




Reputation: 10821
  • View blog
  • Posts: 40,340
  • Joined: 27-December 08

Re: Check if array contains array

Posted 14 August 2010 - 11:29 AM

View Postbcranger, on 14 August 2010 - 12:18 PM, said:

Have to sort to use the binary search method or result will be messed up. Mostyfriendman kindly pointed that out :)

I know that, but [2,4,3] isn't contained [1,2,3,4] unless you sort. So if the OP is concerned about ordering, then sorting + binary search won't work.
Was This Post Helpful? 0
  • +
  • -

#20 bcranger  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 252
  • View blog
  • Posts: 1,199
  • Joined: 01-February 10

Re: Check if array contains array

Posted 14 August 2010 - 11:50 AM

View Postmacosxnerd101, on 14 August 2010 - 10:29 AM, said:

View Postbcranger, on 14 August 2010 - 12:18 PM, said:

Have to sort to use the binary search method or result will be messed up. Mostyfriendman kindly pointed that out :)

I know that, but [2,4,3] isn't contained [1,2,3,4] unless you sort. So if the OP is concerned about ordering, then sorting + binary search won't work.

True, I get your point now :tooth:
Was This Post Helpful? 0
  • +
  • -

  • (2 Pages)
  • +
  • 1
  • 2