Class: String
- Inherits:
-
Object
- Object
- String
- Defined in:
- lib/string.rb
Instance Method Summary collapse
Instance Method Details
#hash_vl ⇒ Object
9 |
# File 'ext/string_hashing/string_hashing.c', line 9 VALUE method_hash_vl(VALUE self, VALUE bitlength); |
#hash_vl_rb(length) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/string.rb', line 7 def hash_vl_rb(length) return 0 if self == "" x = self.bytes.first << 7 m = 1000003 mask = (1<<length) - 1 self.each_byte{ |char| x = ((x * m) ^ char.to_i) & mask } x ^= self.bytes.count x = -2 if x == -1 x end |
#simhash(options = {}) ⇒ Object
2 3 4 5 |
# File 'lib/string.rb', line 2 def simhash(={}) split_by = .delete(:split_by) || " " Simhash.hash(self.split(split_by), ) end |