Skip to content
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

add a check of the existance of a next node #2976

Open
aloayoub opened this issue Mar 9, 2022 · 7 comments
Open

add a check of the existance of a next node #2976

aloayoub opened this issue Mar 9, 2022 · 7 comments

Comments

@aloayoub
Copy link

@aloayoub aloayoub commented Mar 9, 2022

I think here we should first check if there is a next node before lost the reference on first object

https://github.com/TheAlgorithms/Java/blob/master/src/main/java/com/thealgorithms/datastructures/hashmap/hashing/HashMap.java

/**
Linked list class - delete method with the following signature
*/
public void delete(int key) {
if (!isEmpty()) {
if (first.getKey() == key) {
first = null;
} else {
delete(first, key);
}
} else {
System.out.println("List is empty");
}
}

@siriak
Copy link
Member

@siriak siriak commented Mar 15, 2022

Good point, could you make a PR to fix that?

@rajoriaakash
Copy link

@rajoriaakash rajoriaakash commented Mar 20, 2022

Is this issue open?

@siriak
Copy link
Member

@siriak siriak commented Mar 20, 2022

Seems like it is

@chinmaybadhe
Copy link

@chinmaybadhe chinmaybadhe commented Apr 13, 2022

Is this issue still open?

@siriak
Copy link
Member

@siriak siriak commented Apr 14, 2022

@chinmaybadhe yes, it's open

@github-actions
Copy link

@github-actions github-actions bot commented May 15, 2022

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@Sahil3198
Copy link
Contributor

@Sahil3198 Sahil3198 commented May 18, 2022

@siriak I added the proper method to remove the head of the LinkedList in HashMap. So, Now it will work properly. I already raised PR.

Link: #3051

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants