Retrieves, but does not remove, the head of this queue. This method differs from#peek peekonly in that it throws an exception if this queue is empty. Java documentation forjava.util.Queue.element(). Portions of this page are modifications based on work created and shared by theAndroid Open...
peek,element区别: element() 和 peek() 用于在队列的头部查询元素。与 remove() 方法类似,在队列为空时, element() 抛出一个异常,而 peek() 返回 null
boolean add(E e);//如果可以在不违反容量限制的情况下立即将指定的元素插入此队列中。//当使用容量受限队列时,此方法通常优于{add},后者仅通过抛出异常表示插入失败boolean offer(E e);//检测并移除队列的头结点,如果队列为空,抛出异常NoSuchElementExceptionE remove();// 检测并移除队列的头结点,如果队列为...
element() :返回队列头元素但不移除,如果队列为空,则抛出异常 peek() :返回队列头元素但不移除,如果队列为空,则返回null 区别:在取出队列头元素时,如果队列为空,用element()方法则会抛出异常,用peek()方法则会返回null
This interface is a member of theJava Collections Framework. Method Summary All MethodsInstance MethodsAbstract Methods Modifier and TypeMethod and Description booleanadd(Ee) Inserts the specified element into this queue if it is possible to do so immediately without violating capacity restrictions, retu...
this method is generally * preferable to method {@link BlockingQueue#add add}, which can fail to * insert an element only by throwing an exception. * * @throws NullPointerException if the specified element is null */publicbooleanoffer(Ee){if(e==null)thrownewNullPointerException();final Ato...
/** * Inserts the specified element at the tail of this queue. * As the queue is unbounded, this method will never return {@code false}. * * @return {@code true} (as specified by {@link Queue#offer}) * @throws NullPointerException if the specified element is null */ public boolea...
This interface is a member of theJava Collections Framework. Since: 1.5 Method Summary All MethodsInstance MethodsAbstract Methods Modifier and TypeMethod and Description booleanadd(Ee) Inserts the specified element into this queue if it is possible to do so immediately without violating capacity restr...
IJavaObjectIJavaPeerableISerializableIIterableIBlockingQueueICollectionIQueueIDisposable Remarks An optionally-bounded BlockingQueue blocking queue based on linked nodes. This queue orders elements FIFO (first-in-first-out). The head of the queue is that element that has been on the queue the longes...
XmlWriter toXml(XmlWriter xmlWriter, String rootElementName) Methods inherited from java.lang.Object clone equals finalize getClass hashCode notify notifyAll toString wait wait wait Constructor Details QueueMetrics public QueueMetrics() Creates an instance of QueueMetrics class. Method Details fromXm...