dnrajugade / guava-libraries

Automatically exported from code.google.com/p/guava-libraries
Apache License 2.0
0 stars 0 forks source link

Queues#newArrayDeque(int initialCapacity) is missing #1150

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
There's no Queues#newArrayDeque(int) method, which is weird, because 
newLinkedBlockingDeque(int) is present and they were both Java 6 goodies added 
to Guava at same time.

Was this oversight or you haven't decided on name yet? ;) I mean 
Queues#newLinkedBlockingDeque(int) creates *fixed* size collection, but to 
create ArrayList one must use differently named 
Lists#newArrayListWithCapacity(int) method (but that's probably because 
Lists#newArrayListWithExpectedSize(int) is present). Still, I think naming this 
method newArrayDeque is OK.

Original issue reported on code.google.com by xaerx...@gmail.com on 14 Sep 2012 at 3:50

GoogleCodeExporter commented 9 years ago
Q.nAD(int) is a slightly different case than Q.nLBD(int).

The LBD ctor takes an int to indicate a fixed capacity (a specific feature of 
this type).
The AD ctor takes an int to indicate an initial capacity (a pre-alloc 
optimization).

I'll float the idea internally and see what people think though (I did a quick 
search over the Google code base and it would be a fairly useful method).

Original comment by kak@google.com on 14 Sep 2012 at 7:20

GoogleCodeExporter commented 9 years ago
I know the difference, that's why I asked about naming. Static factory 
constructors can be named, which is good, but not easy for API-makers obviously.

That said, personally I'd consider:
- either leaving newLinkedBlockingDeque(int) name as is and adding 
newArrayDeque(int)
- or renaming first to newLinkedBlockingDequeWithFixedSize(int) and naming 
second newArrayDequeWithCapacity(int).

Additionally you may consider adding newArrayDequeWithExpectedSize(int) 
factory, similar to ArrayList's one.

Original comment by xaerx...@gmail.com on 14 Sep 2012 at 9:12

GoogleCodeExporter commented 9 years ago
Any update here? Personally, I've encountered few possible uses for the missing 
static method since reporting this issue.

Original comment by xaerx...@gmail.com on 28 Aug 2013 at 7:12

GoogleCodeExporter commented 9 years ago
This issue has been migrated to GitHub.

It can be found at https://github.com/google/guava/issues/<id>

Original comment by cgdecker@google.com on 1 Nov 2014 at 4:13

GoogleCodeExporter commented 9 years ago

Original comment by cgdecker@google.com on 1 Nov 2014 at 4:18

GoogleCodeExporter commented 9 years ago

Original comment by cgdecker@google.com on 3 Nov 2014 at 9:08