visualization-tool icon indicating copy to clipboard operation
visualization-tool copied to clipboard

Add Negative Keys To Hashmap

Open PureTrippH opened this issue 1 year ago • 5 comments

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

PureTrippH avatar Oct 07 '23 05:10 PureTrippH

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

vercel[bot] avatar Oct 07 '23 05:10 vercel[bot]

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.

https://github.com/RodrigoDLPontes/visualization-tool/assets/67525591/eca0a574-b1c2-406c-9b2f-75312a2b6f97

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).

ljones315 avatar Oct 08 '23 16:10 ljones315

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 avatar Oct 29 '23 20:10 luciankt

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!

luciankt avatar Mar 15 '24 05:03 luciankt

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

PureTrippH avatar Mar 15 '24 05:03 PureTrippH