c++ - How to use stdext::hash_set for custom type in VC++ 2010? -


i want use stdext::hash_set custom type.

in fact realized how so, not sure if correcly (it compilable, looks dirty).

the code follows:

// custom type struct point  {     point(int _x, int _y, int _z) : x(_x), y(_y), z(_z) {}      int x, y, z;      bool operator< (const point& other) const      {         if (x != other.x) return x < other.x;         if (y != other.y) return y < other.y;         return z < other.z;     } };  // helper class struct pointhashcompare {     // value copied ms sources     static const int bucket_size = 1;      size_t operator() (const point& p) const {       return p.x * 31 * 31 + p.y * 31 + p.z;     }      bool operator() (const point& a, const point& b) const {       return < b;     } }; 

and declaration of variable following:

stdext::hash_set<point, pointhashcompare> hset; 

what bucket_size in pointhashcompare mean? microsoft documentation exist explain bucket_size , suggestions value , why required @ all?

(i can suppose connected internal structure of hash-table implementation, different approaches can used , can changed in different vc++ versions)

i considering switch std::unordered_set, wondering how manage stdext::hash_set

thanks!

the integer constant bucket_size specifies mean number of elements per "bucket" (hash-table entry) container should try not exceed. must greater zero. value supplied hash_compare 4.

more info on page hash_compare class


Comments

Popular posts from this blog

jasper reports - Fixed header in Excel using JasperReports -

media player - Android: mediaplayer went away with unhandled events -

python - ('The SQL contains 0 parameter markers, but 50 parameters were supplied', 'HY000') or TypeError: 'tuple' object is not callable -