Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Performance(collection)  RSS feed

 
Sai Chaitanya
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

If i need to iterate a collection and if the collection as 1000 elements when ever a link is triggered to match an id and to dispaly a username.
Will this cause a performance issue.

Please respond asap.
 
Taariq San
Ranch Hand
Posts: 192
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sounds like the wrong Collection.
Why not use a HashMap, storing the id as the key and the username as the value?
 
Vijay Jeyam
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What is the object that you are putting in the collection is that it has a String or Wrapper objects like Integer etc.

NOTE: If you are having your own objects then implement the hashcode and equals in your Class.
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Sai Chaitanya:
Hi All,

If i need to iterate a collection and if the collection as 1000 elements when ever a link is triggered to match an id and to dispaly a username.
Will this cause a performance issue.

Please respond asap.


Probably not. What did you see when you tried it?

Almost all performance issues can only be check by testing. That being said, an 1000 element collection is fairly small, so unless your equality logic is really complex it shouldn't be an issue. But try it, see if its acceptable.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!