I'm trying to write a hash table demo. By using chain to solve hash collision. I want to write some code like below(pseudo code) that to check if the class put in hash table implement operator<
. If the class key_type
implements operator<
, I can use red-black tree to contain the data, otherwise I can only use linked list.
#ifimplement operator<
typedef map<key_type, value_type> bucket_type;
#else
typedef list<pair<key_type, value_type> > bucket_type;
#endif