• Post Reply Bookmark Topic Watch Topic
  • New Topic

Design Code with nested loops

 
Kedarnath Bhagwat
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When you have multiple nested loops to traverse through and set somethings , how do you design the code ?

Do you use Matcher , Visitor Patterns .

How can I ensure that my code is taking minium time to complete the search task .


 
Pat Farrell
Rancher
Posts: 4678
7
Linux Mac OS X VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Number one rule to performance: don't do a lot of stuff.

Well, the real number one rule is that premature optimization is the root of all evil. so the "don't do stuff" is really #2.

Why do you think you need to go through the list multiple times? If the list is "big" this is a bad idea.

The Google Collections library (free, open source, etc.) has very nice functions and predicates that can often be used to do it all with only one pass through the list.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!