singly linked list implementation in java

Learn about singly linked list implementation in java, we have the largest and most updated singly linked list implementation in java information on alibabacloud.com

Basic operation of Linked list Java language implementation

; } returnCurrent ; } //Delete nodes based on the data of the node (delete only the first one) PublicNode Deletebydata (intdata) {Node current=First ; Node previous= First;//Remember the previous node while(Current.data! =data) { if(Current.next = =NULL) { return NULL; } Previous=Current ; Current=Current.next; } if(Current = =First ) { First=First.next; } Else{Previous.next=Current.next; } returnCurrent ; } //Show all the node inf

Stack (storage structure linked list)--java implementation

1 /*implementing stacks with linked lists--chain stacks2 * */3 Public classMylinkedstack {4 Publicmylinkedlist linklist;5 intitems;6 7 PublicMylinkedstack () {8Items = 0;9Linklist =Newmylinkedlist ();Ten } One A Public BooleanIsEmpty () { - returnlinklist.isempty (); - } the - Public voidPushintkey) { - Linklist.insertfirst (key); -items++; + } - + PublicLink Pop () { ALink temp =Linklist.deletefirst (); atitems--; - retur

Queue (storage structure double-ended linked list)--java implementation

1 /*queues implemented with linked lists-using double-ended lists2 * NOTE: null pointer error must be reference not pointing to object3 * */4 Public classMylinkedqueue {5 Privatemyfirstandlastlinkedlist list;6 Private intitems;7 8 PublicMylinkedqueue () {9List =Newmyfirstandlastlinkedlist ();TenItems = 0; One } A - Public BooleanIsEmpty () { - returnList.isEmpty (); the } - - Public voidInsertintkey)

12. Java implementation of doubly linked list

{Last.previous.next =null;last = last.previous;} } public void find (int value)//Find data{Node current = first;while (current.data! = value){Current =current.next;}Current.display ();} public void Finddelete (int value)//Find data and delete{Node current = first; if (First.data ==value){First =first.next;}Else{while (current.data! = value){Current =current.next;}Current.previous.next = Current.next;} } public boolean IsEmpty ()//Determine if the linked

Java implementation: Turn the two-dollar lookup tree into a sorted doubly linked list (tree)

left sub-leaf node of the current element.2. The next element of the doubly linked list constructed by the current node is the smallest node of the right child node of the current node, see 1.3. The previous element of the doubly linked list constructed by the current node is the node of the last operation.The code is as follows:public class Bstreenode {private Integer value;private bstreenode leftnode;pri

Java implementation of doubly linked list

[] n =New int[100]; theArrays.fill (n,-1);113 intVal; the intCount = 0; the while(val = Sc.nextint ()) >= 0) { then[count++] =Val;117 }118 init (n);119 while(true){ - Printlist (head);121Print ("\nplease input the index and NUM to insert");122 intindex =sc.nextint ();123val =sc.nextint ();124 Insert (index, Val); the Printlist (head);126Print ("\nplease input the index to delete");127index =sc.nextint (); - Delete (index);129 Printlist (head)

[Java data structure] 2.4 Single-loop Linked List Implementation

last node to the header node instead of being NULL as a single-linked table. In this case, a new node is inserted after the last node. 2. When determining whether the end of the table is reached, it is to determine whether the value of the node chain domain is the header node. When the Chain Domain value is equal to the header pointer, it indicates that it has reached the end of the table. Instead of determining whether the Chain Domain value is NULL like a single-chain table.

Java list to redo the implementation of the way _java

In the development process, the encounter to generate a list object, you need to check every object inside it. However, this list sometimes has duplicate data. Therefore, it is necessary to go heavy to avoid duplicate checksums. 1. Writing without type: List listwithoutdup = new ArrayList (new HashSet (Listwithdup)); 2. With type (for example, Strin

Pagination query Java code for news list Implementation _java

This example for you to share the News list page query Java code for your reference, the specific content as follows Package com.ibeifeng.test; Create a news test class public class Newtest {private long id; private string title; private string content; private string author; Public Newtest () {super ();} Public newtest (long ID, string title, string content, string author) {this.id = ID; Thi

Java Implementation Web version RSS reader (ii) use Dtree tree to load RSS Subscription grouping list

On the previous blog, Web version RSS reader (i)--dom4j read XML (OPML) file has said how to read the RSS subscription file. This time read the subscribed files to the page and use the tree structure to load the display. Do not intend to use a special control for the tree display, do not want to write their own, want to jingxiang some, just in A JS tree script--dtree was found on the Internet. Dtree is an easy to use JavaScript tree The Menu control. Supports infinite ratings, you can place m

Java learning notes-custom implementation of collections list

/** Custom implementation of the javaslist collection structure */public class my‑list {private node firstnode; // always points to the first element private node lastnode; // always point to the last element private int size; // set length // Add public Boolean add (node) {If (null = node) {Throw new illegalargumentexception ("Node element with null not allowed");} If (null = firstnode) {firstnode = node;

Java implementation single-link list inversion

This paper mainly introduces two methods of single-linked list inversion, which are recorded as follows:1.Package Com.leetcode;public class Listreverse {public static void main (string[] args) {node Node1 = new Node (1); Node Node2 = new node (2); Node Node3 = new node (3); Node Node4 = new node (4); node1.next = Node2;node2.next = Node3;node3.next = Node4; Node head = reverse (Node1); while (head! = null) {System.out.println (head.val); head = Head.n

Implementation of iterators in JAVA list __java

From Java data structure and algorithm book If the node is inserted, current points to the inserted element, and if the node is deleted, then current=current.next; Here's the complete code: Package com.xll; public class Interiterapp {public static void main (string[] args) {singlelinklist singlelinklist = new Singlelink List (); Iteratorlist iteratorlist = Singlelinklist.getiteratorlist (); Iterato

Total Pages: 6 1 2 3 4 5 6 Go to: Go

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.