Win a copy of Escape Velocity: Better Metrics for Agile Teams this week in the Agile and Other Processes forum!
  • 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
  • Liutauras Vilda
  • Tim Cooke
  • Paul Clapham
  • Jeanne Boyarsky
Sheriffs:
  • Ron McLeod
  • Frank Carver
  • Junilu Lacar
Saloon Keepers:
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
Bartenders:
  • Piet Souris
  • Frits Walraven
  • fred rosenberger

modifying a list collections

 
Ranch Hand
Posts: 125
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi All,

I have a method which get a generics list collection object as an input.
The collection contains objects of class TestObj { int id; String name; double amt}. As an input parameter the list is available in the ascending order of id (1,2,3....so on)

Now before i delegate this collection further down we have to modify this collection a bit i.e. based on certain condition we have to rotate some elements to the bottom list.
Since this is an adhoc calculation check I did not go for Comparator /Comparable based ordering.

Here is what I do



This reorder of the list is needed down the line in the app flow. My question here is this appropriate way of doing it or can this be handled in a better fashion


Thanks.
 
Ranch Hand
Posts: 230
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Mohit,

I think sorting your list based on a Comparator is a more straightforward way to do it. It makes it a bit clearer as to what you're trying to do.

Jeff
 
lowercase baba
Posts: 13074
67
Chrome Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I put code tags around your source - it preserves the indenting and makes it easier to read. Next time you post, just click the button above where you enter your text labeled 'code' and it will pop them in for you, then paste your source between them.

Thanks
 
Don't listen to Steve. Just read this tiny ad:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic