Skip to content

Instantly share code, notes, and snippets.

View munificent's full-sized avatar

Bob Nystrom munificent

View GitHub Profile
@ssylvan
ssylvan / rh_hash_table.hpp
Last active January 12, 2023 04:52
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
@nakamura-to
nakamura-to / gist:2144314
Created March 21, 2012 04:22
Visitor Pattern in JavaScript
// see http://d.hatena.ne.jp/ashigeru/20090113/1231855642
var calc = {
add: function (node) {
return visit(this, node.l) + visit(this, node.r);
},
sub: function (node) {
return visit(this, node.l) - visit(this, node.r);
},
val: function (node) {
#!/usr/bin/env ruby
if ARGV.size < 2
$stderr.puts 'usage: monitor <path> <command> [arg1 arg2 ...]'
exit 100
end
PATH = ARGV[0]
COMMAND = ARGV[1]
ARGS = ARGV[2..-1]