I'm having trouble implementing a combination of two double link lists. Here I have my con's method, But as a result I get the tail element of the first list, and all the elements in the second list.
Public node & lt ;? & Gt; Context (node> lieutenant ;? gt; head1, node & gt ;? gt; head 2) {if (head1 == null) {return head2; } If (head 2 == empty) {return head 1; } Node & lt ;? & Gt; N = Head 1; While (n.getNext ()! = Null) {n = n.getNext (); } N.setNext (head2); Return 1}
Edit: Double Linked class:
Public square DoubleLinkedList & lt; E & gt; {Protected Cover Size; Protected node & lt ;? & Gt; Head, tail; Public Double Linkedist () {size = 0; clear(); } Public Zero Clear () {Head = Zero; Tail = null; } Public full size () {return size; } Public boolean is empty () {return head == tap; } Public node & lt ;? & Gt; GetHead () {return head; } Public node & lt ;? & Gt; GetTail () {back tail; } Add Public Zero (E Values) {node & lt; E & gt; Node = new node & lt; E & gt; (value); If (AETT)) {head = node; Tail = node; } And (tail.setset-next (node); node.setPrevious (tail); tail = node;} size ++;} public int indexOf (e value) {node
}
instead of head1
Try returning n
.
No comments:
Post a Comment