On 08.07.2014 4:47, Martin Buchholz wrote:
I think this code has an off-by-factor-of-2 bug.

+        if (expectedMaxSize > MAXIMUM_CAPACITY / 3)
+            return MAXIMUM_CAPACITY;


No, even though it looks like a bug.

(MAXIMUM_CAPACITY / 3) * (3 / 2) == MAXIMUM_CAPACITY / 2.

if expected size > MAXIMUM_CAPACITY / 3,
then the minimum capacity must be > MAXIMUM_CAPACITY / 2
then the minimum capacity == MAXIMUM_CAPACITY.


Reply via email to