HashTable Java... Can you check my code -


I am writing a class for a hash table in java ... can you please make sure that i I am doing fine till now.

I need to store student record objects in .... I am calculating the hash value based on student ID which is a very long type ...

  package proj3; Import java.util.LinkedList; Public class hashtable {linked list & lt; StudentRecord & gt; [] Buckets; Integer shape; Public HashTable () {Size = 10; Start (); } Public hashtable (int initial size) {size = initial size; Start (); } Private Zero Start () (for (int i = 0; i & lt; size; i ++) {bucket [i] = new linked list & lt; student records & gt; ();}} / ** only private Hashstring (strings) for int calculation {int hash = 0; (int i = 0; i & lt; s.length (); i ++) {hash + = s.charAt (i);} return hash % Size;} ** / Private int calculation Hash (long L) {Return (int) (L% size);} In Public Boolean (Student Records sr) {int hash = calculationHash (sr.studentID); LinkedList & LT ; StudentRecord & gt; L = Bucket [hash]; if (l.contains (SR)) {return true;} details lie ;} PublicReply sr ({{Student}} {int hash = calculation Hash (sr.studentID); LinkedList & Student ;; StudentRecord & gt; L = bucket [hash]; if (! L.contains (sr)) {bucket [ Hash] .add (sr);}}}}  

I think you You may want to write unit tests to verify your actual work, your F (R) iendly SO experts are free to investigate the satisfaction.

A good thing beyond simple test cases is the standard JDK Hashmap With your implementation Not to compare the performance; Generate random keys and / or values, insert, remove, and check that the state is equal between the two implementations (they should be the degree that should be).


Comments

Popular posts from this blog

python - Overriding the save method in Django ModelForm -

html - CSS autoheight, but fit content to height of div -

qt - How to prevent QAudioInput from automatically boosting the master volume to 100%? -