• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Storing data from different methods into LinkedList

 
Laura Balsamo
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello all,

Thank you in advance for the assistance. I have a code that I must edit. Currently it features a LinkedList structure with multiple methods throughout various classes adding data into this LinkedList and then printed at the end. I am tasked with changing this so, instead of these methods adding data to the LinkedList throughout the program, it only adds the data at the end (in a separate test class). My trouble is that this structure makes perfect sense to me so I don't know where to start. How do I get data from different methods into this LinkedList without continuously appending it as the methods are executed?

Thanks.
 
Ralph Cook
Ranch Hand
Posts: 479
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The only thing I can think of seems too obvious to be the answer, but you haven't given a lot of details about why someone wants you to do this. It is possible they didn't give you many details either.

If for some reason they want a linked list that gets all its additions "all at once", and the various additions all come from different methods, then all I can think of is to accumulate them in a different linked list, and then transfer them from one to the other "all at once".

I suppose if someone wanted to lock the linked list from alterations before the first addition until after the last one, but didn't want to lock for execution of all the methods, then it might make sense to do this. But it's just a shot in the dark.

rc
 
Campbell Ritchie
Sheriff
Pie
Posts: 50171
79
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And welcome to the Ranch
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic