Skip to content

Commit 192427a

Browse files
sozelfistvil02
andauthored
Parameterize references to generic types. (#5078)
* chore: remove unused imports * fix: parameterize references to generic types --------- Co-authored-by: vil02 <[email protected]>
1 parent ab37184 commit 192427a

File tree

7 files changed

+9
-10
lines changed

7 files changed

+9
-10
lines changed

src/main/java/com/thealgorithms/backtracking/MColoring.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
package com.thealgorithms.backtracking;
22

3-
import java.io.*;
43
import java.util.*;
54

65
/**

src/main/java/com/thealgorithms/datastructures/dynamicarray/DynamicArray.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ public String toString() {
145145
* @return Iterator a Dynamic Array Iterator
146146
*/
147147
@Override
148-
public Iterator iterator() {
148+
public Iterator<E> iterator() {
149149
return new DynamicArrayIterator();
150150
}
151151

src/main/java/com/thealgorithms/datastructures/lists/CircleLinkedList.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ public void append(E value) {
5353

5454
// utility function for traversing the list
5555
public String toString() {
56-
Node p = head.next;
56+
Node<E> p = head.next;
5757
String s = "[ ";
5858
while (p != head) {
5959
s += p.value;
@@ -91,7 +91,7 @@ public E remove(int pos) {
9191
}
9292

9393
public static void main(String[] args) {
94-
CircleLinkedList cl = new CircleLinkedList<String>();
94+
CircleLinkedList<Integer> cl = new CircleLinkedList<>();
9595
cl.append(12);
9696
System.out.println(cl);
9797
cl.append(23);

src/main/java/com/thealgorithms/datastructures/lists/CursorLinkedList.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ public void remove(T element) {
134134
}
135135

136136
private void free(int index) {
137-
Node os_node = cursorSpace[os];
137+
Node<T> os_node = cursorSpace[os];
138138
int os_next = os_node.next;
139139
cursorSpace[os].next = index;
140140
cursorSpace[index].element = null;

src/main/java/com/thealgorithms/misc/ThreeSumProblem.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ public List<List<Integer>> TwoPointer(int[] nums, int target) {
7575

7676
public List<List<Integer>> Hashmap(int[] nums, int target) {
7777
Arrays.sort(nums);
78-
Set<List<Integer>> ts = new HashSet();
78+
Set<List<Integer>> ts = new HashSet<>();
7979
HashMap<Integer, Integer> hm = new HashMap<>();
8080

8181
for (int i = 0; i < nums.length; i++) {
@@ -94,6 +94,6 @@ public List<List<Integer>> Hashmap(int[] nums, int target) {
9494
}
9595
}
9696
}
97-
return new ArrayList(ts);
97+
return new ArrayList<>(ts);
9898
}
9999
}

src/main/java/com/thealgorithms/searches/UnionFind.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public void union(int x, int y) {
4545
}
4646

4747
public int count() {
48-
List parents = new ArrayList();
48+
List<Integer> parents = new ArrayList<>();
4949
for (int i = 0; i < p.length; i++) {
5050
if (!parents.contains(find(i))) {
5151
parents.add(find(i));

src/main/java/com/thealgorithms/strings/WordLadder.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,13 +51,13 @@ class WordLadder {
5151
* if the endword is there. Otherwise, will return the length as 0.
5252
*/
5353
public static int ladderLength(String beginWord, String endWord, List<String> wordList) {
54-
HashSet<String> set = new HashSet(wordList);
54+
HashSet<String> set = new HashSet<>(wordList);
5555

5656
if (!set.contains(endWord)) {
5757
return 0;
5858
}
5959

60-
Queue<String> queue = new LinkedList();
60+
Queue<String> queue = new LinkedList<>();
6161
queue.offer(beginWord);
6262
int level = 1;
6363

0 commit comments

Comments
 (0)