removed unused return values

This commit is contained in:
Doru Kesriyeli
2018-10-07 17:20:32 -07:00
committed by GitHub
parent eb01780ae6
commit ae2029424b

View File

@ -60,13 +60,12 @@ class DoublyLinkedList{
* *
* @return The new head * @return The new head
*/ */
public Link deleteHead(){ public void deleteHead(){
Link temp = head; Link temp = head;
head = head.next; // oldHead <--> 2ndElement(head) head = head.next; // oldHead <--> 2ndElement(head)
head.previous = null; // oldHead --> 2ndElement(head) nothing pointing at old head so will be removed head.previous = null; // oldHead --> 2ndElement(head) nothing pointing at old head so will be removed
if(head == null) if(head == null)
tail = null; tail = null;
return temp;
} }
/** /**
@ -74,11 +73,11 @@ class DoublyLinkedList{
* *
* @return The new tail * @return The new tail
*/ */
public Link deleteTail(){ public void deleteTail(){
Link temp = tail; Link temp = tail;
tail = tail.previous; // 2ndLast(tail) <--> oldTail --> null tail = tail.previous; // 2ndLast(tail) <--> oldTail --> null
tail.next = null; // 2ndLast(tail) --> null tail.next = null; // 2ndLast(tail) --> null
return temp;
} }
/** /**
@ -87,7 +86,7 @@ class DoublyLinkedList{
* @param x element to be deleted * @param x element to be deleted
* @return Link deleted * @return Link deleted
*/ */
public Link delete(int x){ public void delete(int x){
Link current = head; Link current = head;
while(current.value != x) //Find the position to delete while(current.value != x) //Find the position to delete
@ -102,8 +101,7 @@ class DoublyLinkedList{
else{ //Before: 1 <--> 2(current) <--> 3 else{ //Before: 1 <--> 2(current) <--> 3
current.previous.next = current.next; // 1 --> 3 current.previous.next = current.next; // 1 --> 3
current.next.previous = current.previous; // 1 <--> 3 current.next.previous = current.previous; // 1 <--> 3
} }
return current;
} }
/** /**
@ -211,4 +209,4 @@ class Link{
myList.insertOrdered(3); myList.insertOrdered(3);
myList.display(); // <-- 3(head) <--> 10 <--> 13 <--> 23 <--> 67(tail) --> myList.display(); // <-- 3(head) <--> 10 <--> 13 <--> 23 <--> 67(tail) -->
} }
} }