package Queue;/*@author: Roderland@create: 2020年08月11日---17:54*/public class MyLinkedQueue<E> {private Node<E> head;private Node<E> tail;private class Node<E> {E value;Node<E> next;public Node(E value) {this.value = value;}public Node(E value, Node<E> next) {this.value = value;this.next = next;}}public boolean isEmpty() { return head==null; }public void push(E value) {Node<E> node = new Node<>(value);if (isEmpty()) head=tail=node;else {tail.next=node;tail=node;}}public E peek() {checkEmpty();return head.value;}public E pop() {checkEmpty();E o = head.value;head = head.next;return o;}private void checkEmpty() {if (isEmpty()) throw new IndexOutOfBoundsException("队列空");}}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。