Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 7ae7cd3

Browse files
author
Ram swaroop
committed
remove function renamed as 'remove(int)' was clashing with 'remove(E)' when E = Integer
1 parent 377ea5c commit 7ae7cd3

File tree

4 files changed

+6
-11
lines changed

4 files changed

+6
-11
lines changed

src/me/ramswaroop/Main.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package me.ramswaroop;
22

33
import me.ramswaroop.common.*;
4-
import me.ramswaroop.linkedlists.SingleLinkedList;
54

65
import java.util.Scanner;
76

@@ -135,7 +134,7 @@ public static void main(String[] args) {
135134
case 5:
136135
out.println("Enter value:");
137136
item = Integer.parseInt(in.nextLine());
138-
out.println("Removed: " + singleLinkedList.remove(item));
137+
out.println("Removed: " + singleLinkedList.removeItem(item));
139138
singleLinkedList.printList();
140139
break;
141140
case 6:

src/me/ramswaroop/linkedlists/DoubleLinkedList.java renamed to src/me/ramswaroop/common/DoubleLinkedList.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
package me.ramswaroop.linkedlists;
2-
3-
import me.ramswaroop.common.LinkedList;
1+
package me.ramswaroop.common;
42

53
import static java.lang.System.out;
64

@@ -76,7 +74,7 @@ public E remove(int index) {
7674
}
7775

7876
@Override
79-
public boolean remove(E item) {
77+
public boolean removeItem(E item) {
8078
return false;
8179
}
8280

src/me/ramswaroop/common/LinkedList.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ public interface LinkedList<E> {
114114
* @param item
115115
* @return {@code true} if this list contained the specified element
116116
*/
117-
boolean remove(E item);
117+
boolean removeItem(E item);
118118

119119
/**
120120
* Replaces the element at the specified position in this list with the specified element.

src/me/ramswaroop/linkedlists/SingleLinkedList.java renamed to src/me/ramswaroop/common/SingleLinkedList.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
package me.ramswaroop.linkedlists;
2-
3-
import me.ramswaroop.common.LinkedList;
1+
package me.ramswaroop.common;
42

53
import java.util.NoSuchElementException;
64

@@ -122,7 +120,7 @@ public E remove(int index) {
122120
}
123121

124122
@Override
125-
public boolean remove(E item) {
123+
public boolean removeItem(E item) {
126124
isLinkedListEmpty();
127125

128126
if (!contains(item)) return false;

0 commit comments

Comments
 (0)