Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What is LinkedList?

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly introduces "what is LinkedList". In daily operation, I believe many people have doubts about what LinkedList is. The editor consulted all kinds of materials and sorted out simple and easy-to-use methods of operation. I hope it will be helpful for you to answer the doubts about "what is LinkedList?" Next, please follow the editor to study!

LinkedList is a collection of linked lists.

Public class LinkedList extends AbstractSequentialList implements List, Deque, Cloneable, java.io.Serializable

You can find that LinkedList does not implement the RandomAccess interface, which means that for (int I = 0; I) cannot be used.

< size; i++)进行遍历数据 private static class Node { E item; Node next; Node prev; Node(Node prev, E element, Node next) { this.item = element; this.next = next; this.prev = prev; }} 通过节点的数据结构,可以看出来LinkedList是一个双向链表。链表的特性是方便插入和删除界面。 /** * Tells if the argument is the index of an existing element. */private boolean isElementIndex(int index) { return index >

= 0 & & index

< size;}/** * Tells if the argument is the index of a valid position for an * iterator or an add operation. */private boolean isPositionIndex(int index) { return index >

= 0 & & index > 1) {Node x = first; for (int I = 0; I

< index; i++) x = x.next; return x; } else { Node x = last; for (int i = size - 1; i >

Index; iMurt -) x = x.colors; return x;}}

Gets the element of the specified index using a dichotomy algorithm. Although it is still o (n) in terms of time complexity, it does save 1 stroke and 2 times in actual calculation.

Peek () returns directly to the header node

Poll () returns the return node and deletes it in the linked list

At this point, the study of "what is LinkedList" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report