On 4/28/20 9:48 PM, Jason Mehrens wrote:
Looks like It is intentional that unmodifiable queues are not present.  See: 
https://bugs.openjdk.java.net/browse/JDK-5030930.  The same logic would have 
been used for when Deque was added in the following release.

Good find.

Looking at the Queue interface, it adds four mutator methods and two access methods: element() and peek(). These latter two provide only a tiny bit of convenience over an iterator, so an unmodifiable Queue provides hardly any value over Collection. Thus the rationale in JDK-5030930 for not providing an unmodifiable Queue makes sense.

Deque is considerably richer than Queue, not only in mutator methods. It also adds access methods for both ends (null-returning and throwing), with better names, plus a descending iterator. That might make it worthwhile reconsidering an unmodifiable Deque.

s'marks

Reply via email to