Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public boolean remove(Object item)
- {
- int index, origIndex;
- //compute the hash index of item for a table of size n
- index = (item.hashCode()& Integer.MAX_VALUE)%table.length;
- //save the original hash index
- origIndex = index;
- // compute the hash table index
- index = (item.hashCode() & Integer.MAX_VALUE) % table.length;
- // scan the array and return true if item is in list
- while (index != origIndex)
- {
- if(table[index] == null ||
- table[index].deletedData == false && table[index].available == true)
- return false;
- if (table[index].data.equals(item) && table[index].deletedData == false)
- {
- table[index].data = -2;
- table[index].deletedData = true;
- table[index].available = true;
- // decrement hash table size and return true
- hashtableSize--;
- return true;
- }
- index = (index+1)%table.length;
- }
- return false;
- }
Add Comment
Please, Sign In to add comment