• Post Reply Bookmark Topic Watch Topic
  • New Topic

PriorityQueue - initial capacity.  RSS feed

 
Keith Nagle
Ranch Hand
Posts: 65
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi there.
I was looking at class PriorityQueue in the java 5 API
and am having a tough time figuring out what this parameter does exactly?
The API doesn't provide any lucid information in regard to this parameter.
Thank you & regards.
 
Peter Chase
Ranch Hand
Posts: 1970
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The API docs do explain what the capacity is. It's the size of the internal array.

Allowing you to specify an initial capacity is a small optimisation. If you know how many entries you will need, you can save the (tiny) time spent growing the queue to the required size, by sizing it correctly from the start.

Most of the time, you should ignore this parameter, as it is only useful for micro-optimisation.
 
Keith Nagle
Ranch Hand
Posts: 65
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the reply Peter.
That helps clear things up!
Best regards.
K
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!