Home > Back-end >  About unordered_set barrels initialization of a problem
About unordered_set barrels initialization of a problem

Time:09-24


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 2

CodePudding user response:

refer to the second floor chegxy response:
at least print number should can be divided exactly by 2

I don't know what the compiler you use? I use vs2015, print is 128

CodePudding user response:

Codeblock, is Mingw compiler
  • Related