• 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
  • Ron McLeod
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris

Design Code with nested loops

 
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 .


 
Rancher
Posts: 4686
7
Mac OS X VI Editor Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
reply
    Bookmark Topic Watch Topic
  • New Topic