|
|
@@ -7,6 +7,7 @@
|
|
|
#include "../Container/Pair.h"
|
|
|
#include "../Container/Sort.h"
|
|
|
#include "../Container/Vector.h"
|
|
|
+#include "../Math/MathDefs.h"
|
|
|
|
|
|
#include <cassert>
|
|
|
#include <initializer_list>
|
|
|
@@ -491,14 +492,11 @@ public:
|
|
|
{
|
|
|
if (numBuckets == NumBuckets())
|
|
|
return true;
|
|
|
+
|
|
|
if (!numBuckets || numBuckets < Size() / MAX_LOAD_FACTOR)
|
|
|
return false;
|
|
|
|
|
|
- // Check for being power of two
|
|
|
- unsigned check = numBuckets;
|
|
|
- while (!(check & 1u))
|
|
|
- check >>= 1;
|
|
|
- if (check != 1)
|
|
|
+ if (!IsPowerOfTwo(numBuckets))
|
|
|
return false;
|
|
|
|
|
|
AllocateBuckets(Size(), numBuckets);
|