Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

ArrayDeque interface equivalent method with Queue interface

 
Kim Ming Yap
Ranch Hand
Posts: 53
Android C++ Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Marshal
Pie
Posts: 20990
76
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic