aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes ArrayDeque interface equivalent method with Queue interface Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "ArrayDeque interface equivalent method with Queue interface" Watch "ArrayDeque interface equivalent method with Queue interface" New topic
Author

ArrayDeque interface equivalent method with Queue interface

Kim Ming Yap
Ranch Hand

Joined: Dec 17, 2008
Posts: 53

I know that ArrayDeque offers both ends of processing (head and tail) but what i don't understand why the method offerlast() is equivalent to offer() method of Queue interface. Why not offerfirst()? Pleae advice. Thanks
Henry Wong
author
Sheriff

Joined: Sep 28, 2004
Posts: 18896
    
  40

Kim Ming Yap wrote:I know that ArrayDeque offers both ends of processing (head and tail) but what i don't understand why the method offerlast() is equivalent to offer() method of Queue interface. Why not offerfirst()? Pleae advice. Thanks


Design decision. They actually had to pick one... Let's say that the designer chosed offerFirst() instead. And hence, remove is mapped to removeLast(), poll is mapped to pollLast(), etc. etc. etc.

Then I guess you can ask the same question, but instead, why isn't it offerLast()?

Henry


Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: ArrayDeque interface equivalent method with Queue interface