Added string-ci-hash and symbol-hash.

Slight change to ikrt_string_hash.
This commit is contained in:
Abdulaziz Ghuloum 2007-11-22 17:04:10 -05:00
parent c25e04569c
commit 42daf68195
5 changed files with 19 additions and 8 deletions

View File

@ -19,7 +19,7 @@
hashtable-size hashtable-delete! hashtable-contains?
hashtable-update! hashtable-keys hashtable-mutable?
hashtable-clear! hashtable-entries hashtable-copy
string-hash)
string-hash string-ci-hash symbol-hash)
(import
(ikarus system $pairs)
(ikarus system $vectors)
@ -29,7 +29,7 @@
hashtable-size hashtable-delete! hashtable-contains?
hashtable-update! hashtable-keys hashtable-mutable?
hashtable-clear! hashtable-entries hashtable-copy
string-hash))
string-hash string-ci-hash symbol-hash))
(define-struct hasht (vec count tc mutable?))
@ -411,4 +411,15 @@
(foreign-call "ikrt_string_hash" s)
(error 'string-hash "not a string" s)))
(define (string-ci-hash s)
(if (string? s)
(foreign-call "ikrt_string_hash"
(string-foldcase s))
(error 'string-ci-hash "not a string" s)))
(define (symbol-hash s)
(if (symbol? s)
(foreign-call "ikrt_string_hash" (symbol->string s))
(error 'symbol-hash "not a symbol" s)))
)

View File

@ -1 +1 @@
1115
1116

View File

@ -1193,8 +1193,8 @@
[hashtable-equivalence-function r ht]
[equal-hash r ht]
[string-hash i r ht]
[string-ci-hash r ht]
[symbol-hash r ht]
[string-ci-hash i r ht]
[symbol-hash i r ht]
[list-sort i r sr]
[vector-sort i r sr]
[vector-sort! i r sr]

View File

@ -700,8 +700,8 @@
[hashtable-equivalence-function S ht]
[equal-hash S ht]
[string-hash C ht]
[string-ci-hash S ht]
[symbol-hash S ht]
[string-ci-hash C ht]
[symbol-hash C ht]
;;;
[list-sort C sr]
[vector-sort C sr]

View File

@ -53,7 +53,7 @@ compute_hash(ikp str){
ikp
ikrt_string_hash(ikp str){
return fix(compute_hash(str));
return compute_hash(str) & (~ fx_mask);
}
static int strings_eqp(ikp str1, ikp str2){