mirror of
https://github.com/tu-darmstadt-informatik/AuD18.git
synced 2025-12-13 01:45:49 +00:00
Increase insert try cutoff to capacity squared
This commit is contained in:
parent
3e93faca5e
commit
58bd1921bf
@ -112,7 +112,7 @@ public class HashTable {
|
||||
// Find a free or deleted slot to insert the entry
|
||||
while(this.data[address] != null && !this.data[address].isDeleted()) {
|
||||
// Don't insert if there is no more space (this shouldn't happen due to auto-rehashing) or if the key is already present
|
||||
if(i > this.capacity || this.data[address].getKey().equals(insertEntry.getKey()))
|
||||
if(i > Math.pow(this.capacity, 2) || this.data[address].getKey().equals(insertEntry.getKey())) // The try cutoff of n² is pretty much trial and error - definitely safe for linear probing, not sure about quadratic
|
||||
return false;
|
||||
i += 1;
|
||||
address = this.getProbingAddr(base, i);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user