• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Devaka Cooray
  • Ron McLeod
  • Jeanne Boyarsky
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Carey Brown
  • Tim Holloway
Bartenders:
  • Martijn Verburg
  • Frits Walraven
  • Himai Minh

ignoring missing elements in 2D array list

 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I want to compare elements in somewhat a matrix; columnwise ignoring missing, later replace the missing with the adjacent values if equal or fill with na. i.e
s577 A B B
s592
s600 A B A

to

s577 A B B
s592 A B na
s600 A B A

Below is what I have attempted, please bare with my hardcoding. I can't figure out how to efficiently loop. The first filling of "A" goes to end of the list, how to give a specific position! Thanks

       
       
 
Saloon Keeper
Posts: 9742
80
Eclipse IDE Firefox Browser MySQL Database VI Editor Java Windows
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Welcome to the Ranch Glen.

It looks to me like you only need a single map and that each entry has a key and a list of Strings. Additionally, a TreeMap will keep the keys in sorted order, which looks like what you were doing. It's also useful to break things down into smaller methods that only do one task.
 
glen viet
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
@Carey Brown, many thanks for the direction. I am trying to learn a few things about maps, hopefully, I can eventually implement fillAdjacent method as suggested.
 
Never trust an airline that limits their passengers to one carry on iguana. Put this tiny ad in your shoe:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic