aspose file tools*
The moose likes Beginning Java and the fly likes A set containing an array of arrays? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "A set containing an array of arrays?" Watch "A set containing an array of arrays?" New topic
Author

A set containing an array of arrays?

dustin kab
Greenhorn

Joined: Mar 29, 2011
Posts: 7
I was wondering if it is possible to plug an array of arrays into a set.
(I'll refer to array of arrays as 2D arrays to make it easier.)

Basically the problem I have is that my 2d array contains coordinates, and these coordinates get messed up if I make 2 sets and then add the coordinates to it.




Ultimately I want to remove duplicate rows in an array of arrays.
fred rosenberger
lowercase baba
Bartender

Joined: Oct 02, 2003
Posts: 11422
    
  16

well...what happened when you tried it?


There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
dustin kab
Greenhorn

Joined: Mar 29, 2011
Posts: 7
Well there are duplicate points in the array such as:

coordinates[400][0]; //x
coordinates[300][1]; //y


coordinates[400][0]; /x
coordinates[10][1]; //y

using the example:
-- It would remove the second 400 that is found, but then the 10 would be matched up with another X obscuring the points.--

I need to check both x and y, and only remove them if they're both the same as another previous two x and y's.
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18669
    
    8

The "it" which is doing that bad thing must be part of your code; adding objects to a Set never modifies the objects in any way. So the problem is in your code, somewhere.
dustin kab
Greenhorn

Joined: Mar 29, 2011
Posts: 7



(I switched to Lists because Sets were eliminating these points on entry.)

I'm wondering how I could check to see if BOTH of the points were entered earlier, and then remove those 2 points from lists. Keeping every entry unique and lined up correctly.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: A set containing an array of arrays?