<html><head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
Hi Robin,<br>
<br>
This belongs in core-libs.<br>
<br>
<div class="moz-cite-prefix">On 24/05/2023 16:50, Robin Gong wrote:<br>
</div>
<blockquote type="cite" cite="mid:CAENJvPVUXR4NdCz6U6uH+s_tO2JP_vBzv7cjBzdstvxf0pfjTQ@mail.gmail.com">
<div dir="ltr">Hi,
<div><br>
</div>
<div>Recently, I found this constructor
in PriorityBlockingQueue:</div>
<div><br>
</div>
<blockquote class="gmail_quote" style="margin:0px 0px 0px
0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
public PriorityBlockingQueue(int initialCapacity,<br>
Comparator<? super E>
comparator) {<br>
if (initialCapacity < 1)<br>
throw new IllegalArgumentException();<br>
this.comparator = comparator;<br>
this.queue = new Object[Math.max(1, initialCapacity)];<br>
}</blockquote>
<div><br>
</div>
<div>I believe we could change 'Math.max(1, initialCapacity)' to
'initialCapacity'. Since initialCapacity must be greater or
equal to 1.</div>
</div>
</blockquote>
<br>
It looks reasonable to me.<br>
<br>
-- <br>
Regards,<br>
Alexey<br>
<br>
<blockquote type="cite" cite="mid:CAENJvPVUXR4NdCz6U6uH+s_tO2JP_vBzv7cjBzdstvxf0pfjTQ@mail.gmail.com">
<div dir="ltr">
<div><br>
</div>
<div>And also that's how PriorityQueue running.</div>
<div><br>
</div>
<blockquote class="gmail_quote" style="margin:0px 0px 0px
0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
public PriorityQueue(int initialCapacity,<br>
Comparator<? super E>
comparator) {<br>
// Note: This restriction of at least one is not
actually needed,<br>
// but continues for 1.5 compatibility<br>
if (initialCapacity < 1)<br>
throw new IllegalArgumentException();<br>
this.queue = new Object[initialCapacity];<br>
this.comparator = comparator;<br>
}</blockquote>
<div><br>
</div>
<div>Best regarts,</div>
<div>Robin Gong</div>
</div>
</blockquote>
<br>
</body>
</html>