Skip to content

Instantly share code, notes, and snippets.

View shaozhixue's full-sized avatar

shaozhixue shaozhixue

  • alibaba
  • beijing
View GitHub Profile
@shaozhixue
shaozhixue / singleton.hpp
Created June 8, 2022 09:08 — forked from bianjiang/singleton.hpp
A C++11 singleton template with variadic parameters support
//
// __SINGLETON_HPP__
//
// The MIT License (MIT)
// Copyright (c) <2013> <Jiang Bian jbian@uams.edu>
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
@shaozhixue
shaozhixue / rh_hash_table.hpp
Created June 8, 2022 14:56 — forked from ssylvan/rh_hash_table.hpp
Quick'n'dirty Robin Hood hash table implementation. Note, I have implemented this algorithm before, with tons of tests etc. But *this* code was written specifically for the blog post at http://sebastiansylvan.com/post/robin-hood-hashing-should-be-your-default-hash-table-implementation/, it has not been extensively tested so there may be bugs (an…
#define USE_ROBIN_HOOD_HASH 1
#define USE_SEPARATE_HASH_ARRAY 1
template<class Key, class Value>
class hash_table
{
static const int INITIAL_SIZE = 256;
static const int LOAD_FACTOR_PERCENT = 90;
struct elem