Skip to content

Commit

Permalink
Parameterize references to generic types. (TheAlgorithms#5078)
Browse files Browse the repository at this point in the history
* chore: remove unused imports

* fix: parameterize references to generic types


---------

Co-authored-by: vil02 <[email protected]>
  • Loading branch information
sozelfist and vil02 authored Mar 15, 2024
1 parent ab37184 commit 192427a
Show file tree
Hide file tree
Showing 7 changed files with 9 additions and 10 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.thealgorithms.backtracking;

import java.io.*;
import java.util.*;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ public String toString() {
* @return Iterator a Dynamic Array Iterator
*/
@Override
public Iterator iterator() {
public Iterator<E> iterator() {
return new DynamicArrayIterator();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public void append(E value) {

// 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;
Expand Down Expand Up @@ -91,7 +91,7 @@ public E remove(int pos) {
}

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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ public void remove(T element) {
}

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;
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/com/thealgorithms/misc/ThreeSumProblem.java
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public List<List<Integer>> TwoPointer(int[] nums, int target) {

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++) {
Expand All @@ -94,6 +94,6 @@ public List<List<Integer>> Hashmap(int[] nums, int target) {
}
}
}
return new ArrayList(ts);
return new ArrayList<>(ts);
}
}
2 changes: 1 addition & 1 deletion src/main/java/com/thealgorithms/searches/UnionFind.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public void union(int x, int y) {
}

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));
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/com/thealgorithms/strings/WordLadder.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down

0 comments on commit 192427a

Please sign in to comment.