File tree Expand file tree Collapse file tree 5 files changed +43
-0
lines changed Expand file tree Collapse file tree 5 files changed +43
-0
lines changed Original file line number Diff line number Diff line change 2929 hash-table=
3030 hash-table-find
3131 hash-table-count
32+ hash-table-keys
33+ hash-table-values
34+ hash-table-entries
3235 ; ; Low-level iteration
3336 hash-table-cursor-first
3437 hash-table-cursor-last
Original file line number Diff line number Diff line change 513513 (>= cur (vector-length (hash-table-keys-vector ht)))
514514 (unfilled? (vector-ref (hash-table-keys-vector ht) cur))))
515515
516+ ; ; for when cursor-based iteration is unsafe
517+
518+ (define (hash-table-keys ht )
519+ (if (hash-table-mutable? ht)
520+ (let* ((size (hash-table-size ht))
521+ (vec (make-vector size)))
522+ (let loop ((cur (hash-table-cursor-first ht))
523+ (idx 0 ))
524+ (unless (>= idx size)
525+ (vector-set! vec idx (hash-table-cursor-key ht cur))
526+ (loop (hash-table-cursor-next ht cur)
527+ (+ idx 1 )))
528+ vec))
529+ (hash-table-keys-vector ht)))
530+ (define (hash-table-values ht )
531+ (if (hash-table-mutable? ht)
532+ (let* ((size (hash-table-size ht))
533+ (vec (make-vector size)))
534+ (let loop ((cur (hash-table-cursor-first ht))
535+ (idx 0 ))
536+ (unless (>= idx size)
537+ (vector-set! vec idx (hash-table-cursor-value ht cur))
538+ (loop (hash-table-cursor-next ht cur)
539+ (+ idx 1 )))
540+ vec))
541+ (hash-table-values-vector ht)))
542+
543+ (define (hash-table-entries ht )
544+ (values (hash-table-keys ht)
545+ (hash-table-values ht)))
546+
516547(define (hash-table-fold proc seed ht )
517548 (let loop ((cur (hash-table-cursor-first ht))
518549 (acc seed))
Original file line number Diff line number Diff line change 2929 hash-table=
3030 hash-table-find
3131 hash-table-count
32+ hash-table-keys
33+ hash-table-values
34+ hash-table-entries
3235 ; ; Low-level iteration
3336 hash-table-cursor-first
3437 hash-table-cursor-last
Original file line number Diff line number Diff line change 2929 hash-table=
3030 hash-table-find
3131 hash-table-count
32+ hash-table-keys
33+ hash-table-values
34+ hash-table-entries
3235 ; ; Low-level iteration
3336 hash-table-cursor-first
3437 hash-table-cursor-last
Original file line number Diff line number Diff line change 4545 hash-table=
4646 hash-table-find
4747 hash-table-count
48+ hash-table-keys
49+ hash-table-values
50+ hash-table-entries
4851 ; ; Low-level iteration
4952 hash-table-cursor-first
5053 hash-table-cursor-last
You can’t perform that action at this time.
0 commit comments