OCAJP Java 8, OCPJP Java 8
The details of the growth policy are not specified beyond the fact that adding an element has constant amortized time cost.
srinivas sy wrote:LIKE WISE How can we make sure arraylist increases its size by 50%
"Leadership is nature's way of removing morons from the productive flow" - Dogbert
Articles by Winston can be found here
Sometimes the only way things ever got fixed is because people became uncomfortable.
Tim Holloway wrote:The repeated doubling algorithm is used not only on lists, but also on things like the StringBuilder. Presumably there are some scholarly papers that detail why it's a good approach for most cases.
Tim Holloway wrote:Except for hashtables, where a prime number is always a preferable choice.
Campbell Ritchie wrote:Hadn't noticed that. Are you sure that thing about prime numbers is right?
Dave Tolls wrote:From what I've read, when associated with hash functions that use a prime number modulus, it gives the least number of clashes.
"Leadership is nature's way of removing morons from the productive flow" - Dogbert
Articles by Winston can be found here
They definitely don't.Winston Gutkowski wrote: . . . would be true if Java's "hashed" collections used the modulus operator (%), but I'm pretty sure they don't. . . .
You showed up just in time for the waffles! And this tiny ad:
Free, earth friendly heat - from the CodeRanch trailboss
https://www.kickstarter.com/projects/paulwheaton/free-heat
|