Java Queue Learning Deque and Queue__java

Source: Internet
Author: User
Tags throw exception

I can't remember peek poll. A large pile of operations, record the difference deque interface

AddFirst AddLast

Offerfirst Offerlast

Removefirst Removelast

Pollfirst Polllast

GetFirst GetLast

Peekfirst Peeklast

(Push pop stack operation is very good to distinguish) Queue Interface

Add offer offer remove poll element peek

Found Deque interface is corresponding to the queue interface on the basis of the operation of each song xx derived from Xxfirst and xxlast, so we just need to see the difference between the XX method

Add if it doesn't fit, throw the exception illegalstateexception

The difference between an offer and an add is simply that if it doesn't fit, return false

The difference between remove and poll and add and offer similar remove if the queue is an empty throw exception and poll returns null

Elment and peek The pair are also elment if the queue is an empty throw exception and peek returns null but neither of them is back. Delete elements from the queue


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.