Class: CFnv
- Inherits:
-
Object
- Object
- CFnv
- Defined in:
- lib/cfnv.rb,
lib/cfnv/version.rb,
ext/cfnv/cfnv.c
Defined Under Namespace
Classes: Error
Constant Summary collapse
- VERSION =
"0.2.3"
Instance Method Summary collapse
-
#fnv132(arg) ⇒ Object
fnv132 methodを定義.
- #fnv164 ⇒ Object
- #fnv1a32 ⇒ Object
- #fnv1a64 ⇒ Object
Instance Method Details
#fnv132(arg) ⇒ Object
fnv132 methodを定義
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'ext/cfnv/cfnv.c', line 5 static VALUE fnv_fnv132(VALUE self, VALUE arg) { char *str = NULL; uint32_t offset_basis = 2166136261U; uint32_t cFNV_PRIME = 16777619U; uint32_t hash = 0; int i; Check_Type(arg, T_STRING); str = StringValuePtr(arg); int len = strlen(str); hash = offset_basis; for (i = 0; i < len; i++) { hash *= cFNV_PRIME; hash ^= str[i]; } return INT2FIX(hash); } |