欢迎访问 生活随笔!

生活随笔

当前位置: 首页 > 编程资源 > 编程问答 >内容正文

编程问答

deque双向队列的使用

发布时间:2025/1/21 编程问答 40 豆豆
生活随笔 收集整理的这篇文章主要介绍了 deque双向队列的使用 小编觉得挺不错的,现在分享给大家,帮大家做个参考.

Deque的使用

/*** Retrieves and removes the first element of this deque,* or returns {@code null} if this deque is empty.** @return the head of this deque, or {@code null} if this deque is empty*/E pollFirst();/*** Retrieves and removes the last element of this deque,* or returns {@code null} if this deque is empty.** @return the tail of this deque, or {@code null} if this deque is empty*/E pollLast();/*** Retrieves, but does not remove, the first element of this deque.** This method differs from {@link #peekFirst peekFirst} only in that it* throws an exception if this deque is empty.** @return the head of this deque* @throws NoSuchElementException if this deque is empty*/E getFirst();/*** Retrieves, but does not remove, the last element of this deque.* This method differs from {@link #peekLast peekLast} only in that it* throws an exception if this deque is empty.** @return the tail of this deque* @throws NoSuchElementException if this deque is empty*/E getLast();

priotityQueue

remove 是删除最后一个 clear 删除所有的public void clear() {modCount++;for (int i = 0; i < size; i++)queue[i] = null;size = 0;}

总结

以上是生活随笔为你收集整理的deque双向队列的使用的全部内容,希望文章能够帮你解决所遇到的问题。

如果觉得生活随笔网站内容还不错,欢迎将生活随笔推荐给好友。