hashing static const int allowed_rehashes bool inserthelper const anytype xx const int count_limit anytype xxwhiletrue int lastpos - int posforint count count count_limit++count forint numhashfunctions++ pos myhashxi )if!isactivepos arraypos std::movehashentrystd::movex )true )++currentsizereturn true/none of the spots are available evict random one int do pos myhashxr nextintnumhashfunctions )whilepos =lastpos & + )lastpos posstd::swapxarraypos element )if++rehashes allowed_rehashes expand)/make the table bigger rehashes /reset the of rehashes else rehash)/same table sizenew hash functions figure insertion routine for cuckoo hashing uses different algorithm that chooses the item to evict randomlyattempting not to re-evict the last item the table will attempt to select new hash functions (rehashif there are too many evictions and will expand if there are too many rehashes