• Post Reply Bookmark Topic Watch Topic
  • New Topic

Generics : How many levels will not affect performance?  RSS feed

 
amitesh kumar
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,
Welcome Seema,
In my current project I have used Generics extensively. In many cases the declaration is of the following form:

Iterator<Entry<LHSRATE, HashMap<String,RHSRATE>>>.

I want to know if such multilevel declarations affect performanceand if it does upto what level is permissible for a good performance.
Amitesh
 
Andy Morris
Ranch Hand
Posts: 78
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Wrong place to post this.

And don't pre-optimize.
[ August 08, 2006: Message edited by: Andy Morris ]
 
Barry Gaunt
Ranch Hand
Posts: 7729
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Moving to Java In General (Intermediate)
 
Paul Clapham
Sheriff
Posts: 22843
43
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When you say "affect performance", what's your baseline for comparison?
 
Vladimir Nesov
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Generic declarations don't directly affect performance. They matter only compile time.
Btw, it's strange to see HashMap in parameter declaration, it should be possible to use Map instead. In this particular case it may be better to wrap whole HashMap<String,RHSRATE> part in its own class, so that you use only Iterator<Entry<LHSRATE, MyMappingClass>>. In many cases readability may be preferred over performance, so you may consider using this inefficient loop:

[ August 08, 2006: Message edited by: Vladimir Nesov ]
[ August 08, 2006: Message edited by: Vladimir Nesov ]
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!