Correct the comment about the probe sequence. It's (i/2 + i)/2 not (i/2 - i)/2.

Also note that this probe sequence visits every group exactly once.

PiperOrigin-RevId: 446535602
Change-Id: I13169be3f8ee6a4ddbbe8be84f1e1a482444d0cc
pull/1163/merge
Abseil Team 3 years ago committed by Copybara-Service
parent 384a25d5e1
commit e8cda74967
  1. 6
      absl/container/internal/raw_hash_set.h

@ -228,7 +228,7 @@ void SwapAlloc(AllocType& /*lhs*/, AllocType& /*rhs*/,
// //
// Currently, the sequence is a triangular progression of the form // Currently, the sequence is a triangular progression of the form
// //
// p(i) := Width * (i^2 - i)/2 + hash (mod mask + 1) // p(i) := Width * (i^2 + i)/2 + hash (mod mask + 1)
// //
// The use of `Width` ensures that each probe step does not overlap groups; // The use of `Width` ensures that each probe step does not overlap groups;
// the sequence effectively outputs the addresses of *groups* (although not // the sequence effectively outputs the addresses of *groups* (although not
@ -241,6 +241,10 @@ void SwapAlloc(AllocType& /*lhs*/, AllocType& /*rhs*/,
// for selecting candidates. However, when those candidates' slots are // for selecting candidates. However, when those candidates' slots are
// actually inspected, there are no corresponding slots for the cloned bytes, // actually inspected, there are no corresponding slots for the cloned bytes,
// so we need to make sure we've treated those offsets as "wrapping around". // so we need to make sure we've treated those offsets as "wrapping around".
//
// It turns out that this probe sequence visits every group exactly once if the
// number of groups is a power of two, since (i^2+i)/2 is a bijection in
// Z/(2^m). See https://en.wikipedia.org/wiki/Quadratic_probing
template <size_t Width> template <size_t Width>
class probe_seq { class probe_seq {
public: public:

Loading…
Cancel
Save