* cleanup of hash-tables.ss
This commit is contained in:
parent
fcf401b076
commit
81179a5e5d
BIN
src/ikarus.boot
BIN
src/ikarus.boot
Binary file not shown.
|
@ -2,26 +2,15 @@
|
||||||
(library (ikarus hash-tables)
|
(library (ikarus hash-tables)
|
||||||
(export hash-table? make-hash-table get-hash-table put-hash-table!)
|
(export hash-table? make-hash-table get-hash-table put-hash-table!)
|
||||||
(import
|
(import
|
||||||
(only (scheme) $set-car! $set-cdr! $car $cdr $fxlogxor $fxsra
|
(ikarus system $pairs)
|
||||||
$fxsll $fxlognot $fx+ $fx- $fx= $fx> $fxadd1
|
(ikarus system $vectors)
|
||||||
$vector-length $vector-ref $vector-set!
|
(ikarus system $tcbuckets)
|
||||||
$make-tcbucket $set-tcbucket-val!
|
(ikarus system $fx)
|
||||||
$tcbucket-next $tcbucket-key $set-tcbucket-next!
|
|
||||||
$tcbucket-val $set-tcbucket-tconc! $fxlogand)
|
|
||||||
(except (ikarus) hash-table? make-hash-table get-hash-table
|
(except (ikarus) hash-table? make-hash-table get-hash-table
|
||||||
put-hash-table!))
|
put-hash-table!))
|
||||||
|
|
||||||
(define-record hasht (vec count tc))
|
(define-record hasht (vec count tc))
|
||||||
|
|
||||||
;(let ([hash-rtd (make-record-type '"hash-table" '(hash-vec count tc))])
|
|
||||||
; ;;; accessors
|
|
||||||
; (define get-vec (record-field-accessor hash-rtd 0))
|
|
||||||
; (define set-vec! (record-field-mutator hash-rtd 0))
|
|
||||||
; (define get-count (record-field-accessor hash-rtd 1))
|
|
||||||
; (define set-count! (record-field-mutator hash-rtd 1))
|
|
||||||
; (define get-tc (record-field-accessor hash-rtd 2))
|
|
||||||
;;; implementation
|
|
||||||
|
|
||||||
;;; directly from Dybvig's paper
|
;;; directly from Dybvig's paper
|
||||||
(define tc-pop
|
(define tc-pop
|
||||||
(lambda (tc)
|
(lambda (tc)
|
||||||
|
@ -119,28 +108,6 @@
|
||||||
($vector-set! vec idx b)
|
($vector-set! vec idx b)
|
||||||
(void))))))))
|
(void))))))))
|
||||||
|
|
||||||
|
|
||||||
;(define hash-remove!
|
|
||||||
; (lambda (h x)
|
|
||||||
; (let ([vec (get-vec h)]
|
|
||||||
; [next ($tcbucket-next b)])
|
|
||||||
; ;;; first remove it from its old place
|
|
||||||
; (let ([idx
|
|
||||||
; (if (fixnum? next)
|
|
||||||
; next
|
|
||||||
; (get-bucket-index next))])
|
|
||||||
; (let ([fst ($vector-ref vec idx)])
|
|
||||||
; (cond
|
|
||||||
; [(eq? fst b)
|
|
||||||
; ($vector-set! vec idx next)]
|
|
||||||
; [else
|
|
||||||
; (replace! fst b next)]))))
|
|
||||||
; (let ([b1 ($tcbucket-dlink-next b)]
|
|
||||||
; [b2 ($tcbucket-dlink-prev b)])
|
|
||||||
; ($set-tcbucket-dlink-next! b2 b1)
|
|
||||||
; ($set-tcbucket-dlink-prev! b1 b2)
|
|
||||||
; (void))))
|
|
||||||
|
|
||||||
(define get-hash
|
(define get-hash
|
||||||
(lambda (h x v)
|
(lambda (h x v)
|
||||||
(let ([pv (pointer-value x)]
|
(let ([pv (pointer-value x)]
|
||||||
|
@ -154,7 +121,6 @@
|
||||||
(lambda (b)
|
(lambda (b)
|
||||||
($tcbucket-val b))]
|
($tcbucket-val b))]
|
||||||
[else v])))))))
|
[else v])))))))
|
||||||
|
|
||||||
|
|
||||||
(define put-hash!
|
(define put-hash!
|
||||||
(lambda (h x v)
|
(lambda (h x v)
|
||||||
|
@ -213,8 +179,6 @@
|
||||||
(move-all vec1 0 n1 vec2 ($fx- n2 1))
|
(move-all vec1 0 n1 vec2 ($fx- n2 1))
|
||||||
(set-hasht-vec! h vec2))))
|
(set-hasht-vec! h vec2))))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
(define init-vec
|
(define init-vec
|
||||||
(lambda (v i n)
|
(lambda (v i n)
|
||||||
(if ($fx= i n)
|
(if ($fx= i n)
|
||||||
|
|
Loading…
Reference in New Issue