On Thu, Jun 28, 2018 at 11:42 PM, Alex Foster <alexfos...@hotmail.ca> wrote:
> Another question is whether or not it should allow null elements. > ArrayDeque currently doesn't but I think it would be useful to support > them, which makes having an asList() view or sharing code harder. > JDK has moved away from null elements in collections. We want the new collection to implement both List and Deque, and the spec says """ While Deque implementations are not strictly required to prohibit the insertion of null elements, they are strongly encouraged to do so. Users of any Dequeimplementations that do allow null elements are strongly encouraged *not* to take advantage of the ability to insert nulls. This is so because null is used as a special return value by various methods to indicate that the deque is empty. """ --- Another idea is to simply add all of those List-like methods to ArrayDeque without actually implementing List. Then we have maximal efficiency (no wrappers), we don't have to come up with a new name for the class, and a user who wants a genuine 100% List view can do subList(deq, 0, deq.size()). In the past we've been reluctant to do such a strange thing ...