基于整数的hash算法介绍
基于整数的hash算法介绍
structhash_set_func
{
enum
{//parametersforhashtable
bucket_size=2,//0<bucket_size
min_buckets=8
};//min_buckets=2^^N,0<N
size_toperator()(constPointBidAskEntry&v)const
{
size_tkey=v;
key+=~(key<<15);
key^=(key>>10);
key+=(key<<3);
key^=(key>>6);
key+=~(key<<11);
key^=(key>>16);
returnkey;
}
booloperator()(constPointBidAskEntry&_Keyval1,constPointBidAskEntry&_Keyval2)const
{//testif_Keyval1orderedbefore_Keyval2
return(gt(_Keyval1,_Keyval2));
}
greater<PointBidAskEntry>gt;
};
{
enum
{//parametersforhashtable
bucket_size=2,//0<bucket_size
min_buckets=8
};//min_buckets=2^^N,0<N
size_toperator()(constPointBidAskEntry&v)const
{
size_tkey=v;
key+=~(key<<15);
key^=(key>>10);
key+=(key<<3);
key^=(key>>6);
key+=~(key<<11);
key^=(key>>16);
returnkey;
}
booloperator()(constPointBidAskEntry&_Keyval1,constPointBidAskEntry&_Keyval2)const
{//testif_Keyval1orderedbefore_Keyval2
return(gt(_Keyval1,_Keyval2));
}
greater<PointBidAskEntry>gt;
};