Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

A set containing an array of arrays?

 
dustin kab
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 12146
30
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
well...what happened when you tried it?
 
dustin kab
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Sheriff
Posts: 21129
32
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator



(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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic