Parameterize references to generic types. (#5078)
* chore: remove unused imports * fix: parameterize references to generic types --------- Co-authored-by: vil02 <65706193+vil02@users.noreply.github.com>
This commit is contained in:
parent
ab371843ac
commit
192427a5d2
@ -1,6 +1,5 @@
|
||||
package com.thealgorithms.backtracking;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
|
@ -145,7 +145,7 @@ public class DynamicArray<E> implements Iterable<E> {
|
||||
* @return Iterator a Dynamic Array Iterator
|
||||
*/
|
||||
@Override
|
||||
public Iterator iterator() {
|
||||
public Iterator<E> iterator() {
|
||||
return new DynamicArrayIterator();
|
||||
}
|
||||
|
||||
|
@ -53,7 +53,7 @@ public class CircleLinkedList<E> {
|
||||
|
||||
// utility function for traversing the list
|
||||
public String toString() {
|
||||
Node p = head.next;
|
||||
Node<E> p = head.next;
|
||||
String s = "[ ";
|
||||
while (p != head) {
|
||||
s += p.value;
|
||||
@ -91,7 +91,7 @@ public class CircleLinkedList<E> {
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
CircleLinkedList cl = new CircleLinkedList<String>();
|
||||
CircleLinkedList<Integer> cl = new CircleLinkedList<>();
|
||||
cl.append(12);
|
||||
System.out.println(cl);
|
||||
cl.append(23);
|
||||
|
@ -134,7 +134,7 @@ public class CursorLinkedList<T> {
|
||||
}
|
||||
|
||||
private void free(int index) {
|
||||
Node os_node = cursorSpace[os];
|
||||
Node<T> os_node = cursorSpace[os];
|
||||
int os_next = os_node.next;
|
||||
cursorSpace[os].next = index;
|
||||
cursorSpace[index].element = null;
|
||||
|
@ -75,7 +75,7 @@ public class ThreeSumProblem {
|
||||
|
||||
public List<List<Integer>> Hashmap(int[] nums, int target) {
|
||||
Arrays.sort(nums);
|
||||
Set<List<Integer>> ts = new HashSet();
|
||||
Set<List<Integer>> ts = new HashSet<>();
|
||||
HashMap<Integer, Integer> hm = new HashMap<>();
|
||||
|
||||
for (int i = 0; i < nums.length; i++) {
|
||||
@ -94,6 +94,6 @@ public class ThreeSumProblem {
|
||||
}
|
||||
}
|
||||
}
|
||||
return new ArrayList(ts);
|
||||
return new ArrayList<>(ts);
|
||||
}
|
||||
}
|
||||
|
@ -45,7 +45,7 @@ public class UnionFind {
|
||||
}
|
||||
|
||||
public int count() {
|
||||
List parents = new ArrayList();
|
||||
List<Integer> parents = new ArrayList<>();
|
||||
for (int i = 0; i < p.length; i++) {
|
||||
if (!parents.contains(find(i))) {
|
||||
parents.add(find(i));
|
||||
|
@ -51,13 +51,13 @@ class WordLadder {
|
||||
* if the endword is there. Otherwise, will return the length as 0.
|
||||
*/
|
||||
public static int ladderLength(String beginWord, String endWord, List<String> wordList) {
|
||||
HashSet<String> set = new HashSet(wordList);
|
||||
HashSet<String> set = new HashSet<>(wordList);
|
||||
|
||||
if (!set.contains(endWord)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
Queue<String> queue = new LinkedList();
|
||||
Queue<String> queue = new LinkedList<>();
|
||||
queue.offer(beginWord);
|
||||
int level = 1;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user