Skip to content
Permalink
Browse files

Use quadratic probing for collisions

  • Loading branch information...
bobbymcr committed Jun 8, 2019
1 parent efa79c6 commit 07be9ce3664372828e543df2ae69b3280860e647
Showing with 7 additions and 7 deletions.
  1. +7 −7 src/Words.Native.Core/Hashtable.h
@@ -65,7 +65,7 @@ namespace Words
return true;
}

next_index(index);
next_index(index, i);
}

return false;
@@ -96,7 +96,7 @@ namespace Words
return false;
}

next_index(index);
next_index(index, i);
}

insert_new(index, key, value);
@@ -161,17 +161,17 @@ namespace Words
return;
}

next_index(index);
next_index(index, i);
}
}

void next_index(int& index) const
void next_index(int& index, int c) const
{
++index;
index += 1 + (2 * c);
int n = static_cast<int>(buckets_.size());
if (index == n)
if (index >= n)
{
index = 0;
index = index % n;
}
}
};

0 comments on commit 07be9ce

Please sign in to comment.
You can’t perform that action at this time.