Java_ Queue interface

Queue interface

  1. english

A) queue

B) deque, double Ender queue

  2. Queue interface

In addition to the basic collection operations, queues also provide other insert, extract, and check operations. Each method has two forms: one is to throw an exception (when the operation fails), and the other is to return a special value (null or false, depending on the operation). The latter form of insert operation is specially designed for queue implementation with capacity constraints; in most implementations, insert operation will not fail.

< / td > < td > < p align = "left" > element() gets, but does not remove the header of this queue.

< / td > < td > < p align = "left" > offer (< a title = "type parameter in queue" > e) inserts the specified element into this queue (if it is feasible immediately and does not violate the capacity limit). When using a queue with capacity limit, this method is usually better than add (E), which may not be able to insert elements and just throw an exception.

< / td > < td > < p align = "left" > peek() gets but does not remove the header of this queue; Null if the queue is empty.

< / td > < td > < p align = "left" > poll() gets and removes the header of the queue. If the queue is empty, it returns null.

< / td > < td > < p align = "left" > remove() gets and removes the header of this queue.

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>