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:
SOZEL 2024-03-16 01:03:27 +07:00 committed by GitHub
parent ab371843ac
commit 192427a5d2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
7 changed files with 9 additions and 10 deletions

View File

@ -1,6 +1,5 @@
package com.thealgorithms.backtracking; package com.thealgorithms.backtracking;
import java.io.*;
import java.util.*; import java.util.*;
/** /**

View File

@ -145,7 +145,7 @@ public class DynamicArray<E> implements Iterable<E> {
* @return Iterator a Dynamic Array Iterator * @return Iterator a Dynamic Array Iterator
*/ */
@Override @Override
public Iterator iterator() { public Iterator<E> iterator() {
return new DynamicArrayIterator(); return new DynamicArrayIterator();
} }

View File

@ -53,7 +53,7 @@ public class CircleLinkedList<E> {
// utility function for traversing the list // utility function for traversing the list
public String toString() { public String toString() {
Node p = head.next; Node<E> p = head.next;
String s = "[ "; String s = "[ ";
while (p != head) { while (p != head) {
s += p.value; s += p.value;
@ -91,7 +91,7 @@ public class CircleLinkedList<E> {
} }
public static void main(String[] args) { public static void main(String[] args) {
CircleLinkedList cl = new CircleLinkedList<String>(); CircleLinkedList<Integer> cl = new CircleLinkedList<>();
cl.append(12); cl.append(12);
System.out.println(cl); System.out.println(cl);
cl.append(23); cl.append(23);

View File

@ -134,7 +134,7 @@ public class CursorLinkedList<T> {
} }
private void free(int index) { private void free(int index) {
Node os_node = cursorSpace[os]; Node<T> os_node = cursorSpace[os];
int os_next = os_node.next; int os_next = os_node.next;
cursorSpace[os].next = index; cursorSpace[os].next = index;
cursorSpace[index].element = null; cursorSpace[index].element = null;

View File

@ -75,7 +75,7 @@ public class ThreeSumProblem {
public List<List<Integer>> Hashmap(int[] nums, int target) { public List<List<Integer>> Hashmap(int[] nums, int target) {
Arrays.sort(nums); Arrays.sort(nums);
Set<List<Integer>> ts = new HashSet(); Set<List<Integer>> ts = new HashSet<>();
HashMap<Integer, Integer> hm = new HashMap<>(); HashMap<Integer, Integer> hm = new HashMap<>();
for (int i = 0; i < nums.length; i++) { for (int i = 0; i < nums.length; i++) {
@ -94,6 +94,6 @@ public class ThreeSumProblem {
} }
} }
} }
return new ArrayList(ts); return new ArrayList<>(ts);
} }
} }

View File

@ -45,7 +45,7 @@ public class UnionFind {
} }
public int count() { public int count() {
List parents = new ArrayList(); List<Integer> parents = new ArrayList<>();
for (int i = 0; i < p.length; i++) { for (int i = 0; i < p.length; i++) {
if (!parents.contains(find(i))) { if (!parents.contains(find(i))) {
parents.add(find(i)); parents.add(find(i));

View File

@ -51,13 +51,13 @@ class WordLadder {
* if the endword is there. Otherwise, will return the length as 0. * if the endword is there. Otherwise, will return the length as 0.
*/ */
public static int ladderLength(String beginWord, String endWord, List<String> wordList) { 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)) { if (!set.contains(endWord)) {
return 0; return 0;
} }
Queue<String> queue = new LinkedList(); Queue<String> queue = new LinkedList<>();
queue.offer(beginWord); queue.offer(beginWord);
int level = 1; int level = 1;