Skip to content

Parameterize references to generic types. #5078

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Mar 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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