新认识了一个类----Queue
来源:互联网 发布:nba2k online球星数据 编辑:程序博客网 时间:2024/06/05 08:00
java.util.Queue<String>
Throws exception Returns special value
Insert add(e) offer(e)
Remove remove() poll()
Examine element() peek()
Queues typically, but do not necessarily, order elements in a FIFO (first-in-first-out) manner. Among the exceptions are priority queues, which order elements according to a supplied comparator, or the elements' natural ordering, and LIFO queues (or stacks) which order the elements LIFO (last-in-first-out). Whatever the ordering used, the head of the queue is that element which would be removed by a call to remove() or poll(). In a FIFO queue, all new elements are inserted at the tail of the queue. Other kinds of queues may use different placement rules. Every Queue implementation must specify its ordering properties.
The offer method inserts an element if possible, otherwise returning false. This differs from the Collection.add method, which can fail to add an element only by throwing an unchecked exception. The offer method is designed for use when failure is a normal, rather than exceptional occurrence, for example, in fixed-capacity (or "bounded") queues.
The remove() and poll() methods remove and return the head of the queue. Exactly which element is removed from the queue is a function of the queue's ordering policy, which differs from implementation to implementation. The remove() and poll() methods differ only in their behavior when the queue is empty: the remove() method throws an exception, while the poll() method returns null.
The element() and peek() methods return, but do not remove, the head of the queue.
The Queue interface does not define the blocking queue methods, which are common in concurrent programming. These methods, which wait for elements to appear or for space to become available, are defined in the BlockingQueue interface, which extends this interface.
Queue implementations generally do not allow insertion of null elements, although some implementations, such as LinkedList, do not prohibit insertion of null. Even in the implementations that permit it, null should not be inserted into a Queue, as null is also used as a special return value by the poll method to indicate that the queue contains no elements.
Queue implementations generally do not define element-based versions of methods equals and hashCode but instead inherit the identity based versions from class Object, because element-based equality is not always well-defined for queues with the same elements but different ordering properties.
See Also
Collection
LinkedList
PriorityQueue
LinkedBlockingQueue
BlockingQueue
ArrayBlockingQueue
LinkedBlockingQueue
PriorityBlockingQueue
Summary
Throws exception Returns special value
Insert add(e) offer(e)
Remove remove() poll()
Examine element() peek()
Queues typically, but do not necessarily, order elements in a FIFO (first-in-first-out) manner. Among the exceptions are priority queues, which order elements according to a supplied comparator, or the elements' natural ordering, and LIFO queues (or stacks) which order the elements LIFO (last-in-first-out). Whatever the ordering used, the head of the queue is that element which would be removed by a call to remove() or poll(). In a FIFO queue, all new elements are inserted at the tail of the queue. Other kinds of queues may use different placement rules. Every Queue implementation must specify its ordering properties.
The offer method inserts an element if possible, otherwise returning false. This differs from the Collection.add method, which can fail to add an element only by throwing an unchecked exception. The offer method is designed for use when failure is a normal, rather than exceptional occurrence, for example, in fixed-capacity (or "bounded") queues.
The remove() and poll() methods remove and return the head of the queue. Exactly which element is removed from the queue is a function of the queue's ordering policy, which differs from implementation to implementation. The remove() and poll() methods differ only in their behavior when the queue is empty: the remove() method throws an exception, while the poll() method returns null.
The element() and peek() methods return, but do not remove, the head of the queue.
The Queue interface does not define the blocking queue methods, which are common in concurrent programming. These methods, which wait for elements to appear or for space to become available, are defined in the BlockingQueue interface, which extends this interface.
Queue implementations generally do not allow insertion of null elements, although some implementations, such as LinkedList, do not prohibit insertion of null. Even in the implementations that permit it, null should not be inserted into a Queue, as null is also used as a special return value by the poll method to indicate that the queue contains no elements.
Queue implementations generally do not define element-based versions of methods equals and hashCode but instead inherit the identity based versions from class Object, because element-based equality is not always well-defined for queues with the same elements but different ordering properties.
See Also
Collection
LinkedList
PriorityQueue
LinkedBlockingQueue
BlockingQueue
ArrayBlockingQueue
LinkedBlockingQueue
PriorityBlockingQueue
Summary
- 新认识了一个类----Queue
- 今天认识了位新女神
- 今天遇见一个朋友,新认识的
- 新认识的一个ORM框架 guzz
- 认识java中的Queue:
- 新开了一个BLOG
- 新买了一个本
- 换了一个新工作
- 新注册了一个用户
- 搞了一个新网站
- 建了一个新博客
- 建了一个新博客
- 新公司一个月了
- 新认识
- 新发一个博客,很高兴认识大家
- 从最近一个项目中的问题产生的新认识
- 从头认识java-9.11 Queue
- 笔记:C++类的新认识
- 一步一步学习Ubuntu之中文输入法篇
- windows下面使用linux命令的一些方法
- 最小生成树
- 软件漏洞聚合和管理系统 ThreadFix
- WINCE6.0 驱动音量调节的实现
- 新认识了一个类----Queue
- 如何解决win7开机假死
- 解析bind1st和bind2nd的使用
- 虚拟机Ubuntu 12.04 LTS上搭建DHCP服务器流程
- Oracle跟踪文件
- 数据结构实验 单链表
- API读取写入 ini文件内容的方法函数详解
- poj 1961 Period
- 精读OSAL --SPI方式串行通信(_hal_uart_spi.c)