• Post Reply Bookmark Topic Watch Topic
  • New Topic

removing duplicate rows in a two dimensional array  RSS feed

 
kevin comario
Ranch Hand
Posts: 65
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How do remove duplicate rows in a two dimensional array.
I am trying to compare one row to all the others how would i do that?
 
Stan James
(instanceof Sidekick)
Ranch Hand
Posts: 8791
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'll call your outer array rows and the inner one columns, kinda like a resultset.
I started thinking I'd want to get these rows in some kind of order, so I only have to compare each row to the next one rather than to every other row. That would call for a sorting key or unique identifier. That would lend itself to a map with a key and a row object (array of columns). Put all the rows into a map, let it handle duplicate keys, then pull them all out again.
Or maybe you could have an array of objects instead of an array of arrays. Then the objects in the array could implement equals(). Then you could put them all into a Set to handle duplicates and pull them out again. Hmmm, can you try a Set of Objects instead of an array of arrays?
Any of those ideas sound like something you can use?
 
kevin comario
Ranch Hand
Posts: 65
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the ideas. I would have never thought of an array of objects. Thanks
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!