同步操作将从 Gitee Community/bullshit-codes 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
public class LinkedList<E> {/*** The root of the list keeps a reference to both the first and last* elements of the list.*/private LinkedListNode<E> head;/*** Creates a new linked list.*/public LinkedList() {head = new LinkedListNode<>();}/*** Returns the first linked list node in the list.** @return the first element of the list.*/public LinkedListNode<E> getFirst() {LinkedListNode<E> node = head.next;if (node == head) {return null;}return node;}/*** Returns the last linked list node in the list.** @return the last element of the list.*/public LinkedListNode<E> getLast() {LinkedListNode<E> node = head.previous;if (node == head) {return null;}return node;}/*** Adds a node to the beginning of the list.** @param node the node to add to the beginning of the list.*/public LinkedListNode<E> addFirst(LinkedListNode<E> node) {return node.insert(head.next, head);}/*** Adds an object to the beginning of the list by automatically creating a a* new node and adding it to the beginning of the list.** @param object the object to add to the beginning of the list.* @return the node created to wrap the object.*/public LinkedListNode<E> addFirst(E object) {return new LinkedListNode<>(object, head.next, head);}/*** Adds a node to the end of the list.** @param node the node to add to the beginning of the list.*/public LinkedListNode<E> addLast(LinkedListNode<E> node) {return node.insert(head, head.previous);}/*** Adds an object to the end of the list by automatically creating a a new node and adding it to the end of the list.** @param object the object to add to the end of the list.* @return the node created to wrap the object.*/public LinkedListNode<E> addLast(E object) {return new LinkedListNode<>(object, head, head.previous);}/*** Erases all elements in the list and re-initializes it.*/public void clear() {// Remove all references in the list.LinkedListNode<E> node = getLast();while (node != null) {node.remove();node = getLast();}// Re-initialize.head.next = head.previous = head;}/*** Returns a String representation of the linked list with a comma delimited* list of all the elements in the list.** @return a String representation of the LinkedList.*/@Overridepublic String toString() {LinkedListNode<E> node = head.next;StringBuilder buf = new StringBuilder();while (node != head) {buf.append(node.toString()).append(", ");node = node.next;}return buf.toString();}}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。