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 Negative Keys To Hashmap #297

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

PureTrippH
Copy link

  • Changed the Remainder operation to a true modulus operation
  • Enabled negative numbers in any Key Fields

@vercel
Copy link

vercel bot commented Oct 7, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
visualization-tool ❌ Failed (Inspect) Mar 14, 2024 5:26pm

@ljones315
Copy link
Collaborator

ljones315 commented Oct 8, 2023

Nice! Can we constrain the key field to only take '-' and integers though? Right now you're able to input any string which leads to funky stuff.

Screen.Recording.2023-10-08.at.12.13.23.PM.mov

You could either add a constraint to the input field so that only those characters can be typed, or a constraint after submitting that causes the button to shake and displays a message saying "you can only input positive/negative integers" (similar to how it does now on some of the algos like sorting and pattern matching).

@luciankt
Copy link
Collaborator

Played around with these changes and it looks great!! I like that it automatically switches the hashing type if you put something different. Not sure if maybe non-alphanumeric keys like commas should still be filtered out, but up to you.

@luciankt
Copy link
Collaborator

Good stuff! I'm noticing that the True Hash Function type doesn't seem to let anything be entered (see gif here). Maybe this is an issue with line 267 in Hash.js where we set the desiredMode to either string or integer, but never true?

Nitpick: I can enter something like "3aaa" for the integer option as long as the first character is an integer, but I can't put "3aaa" for the string option. The first makes sense to allow duplicate numerical values although that's not super relevant in hashmaps. But for the second point, I think it would makes sense to allow any string including ones with leading integers - just maybe not integers by themselves since that could be confusing to users. Just a thought though, it's fine as is.

If we can get the True Hash Function validation fixed then this is good to go!

@PureTrippH
Copy link
Author

Yeah noticed that on my end. Looks like the repository is having some formatting issues and is conflicting with previous versions. Also, I have no idea how I just noticed the pull request like 4 months later xd

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

Successfully merging this pull request may close these issues.

3 participants