As shown in figure, why initialization barrels to 100, the printing results for 103 barrels.
CodePudding user response:
void rehash (size_type _Buckets)
{//rebuild table with the at further _Buckets buckets
Size_type _Maxsize=_Vec. Max_size ()/4;
Size_type _Newsize=_Min_buckets;
for (; _Newsize & lt; _Buckets & amp; & _Newsize & lt; _Maxsize; )
_Newsize *=2;//double until big enough
If (_Newsize & lt; _Buckets)
_Xout_of_range (" invalid hash bucket count ");
while (! (size ()/max_load_factor () & lt; _Newsize)
& & _Newsize & lt; _Maxsize)
_Newsize *=2;//double until the load factor okay
_Init (_Newsize);
_Reinsert ();
}
This is the source code, unordered_set constructor
_Buckets is you provide the parameters of the constructor,
CodePudding user response:
At least print number should be divided exactly by 2CodePudding user response: