Sha256: 094ffa77264eb49765202d5e05fc2019a13235212d8a160dd36401c3cdcf0be0
Contents?: true
Size: 694 Bytes
Versions: 1
Compression:
Stored size: 694 Bytes
Contents
#! /usr/bin/env ruby lib = File.expand_path('../../lib', __FILE__) $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) require 'overflow' def murmur_hash str data = str.dup.unpack("C*") m = 0x5bd1e995 r = 16 length = Overflow.new "I", str.bytesize h = length * m while 4 <= length d = data.shift(4).pack("C*").unpack("I")[0] h += d h *= m h ^= h >> r length -= 4 end if 2 < length h += data[2] << 16 end if 1 < length h += data[1] << 8 end if 0 < length h += data[0] h *= m h ^= h >> r end h *= m h ^= h >> 10 h *= m h ^= h >> 17 h.to_i end # p murmur_hash "murmur" #=> 2800467524 puts murmur_hash ARGV[0]
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
overflow-0.1.0 | example/murmurhash.rb |