mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-06-26 13:10:22 +02:00
add hash-count for native tables
* libguile/hashtab.c (scm_hash_count): New function. Count the number of elements in a hash table. * doc/ref/api-compound.texi (Hash Tables): Update examples and reference. * test-suite/tests/hash.test (hash-count): New test.
This commit is contained in:
parent
3d2b2676e3
commit
3330f00f54
4 changed files with 73 additions and 2 deletions
|
@ -292,3 +292,19 @@
|
|||
exception:wrong-type-arg
|
||||
(hashx-set! (lambda (k s) 1) (lambda (k al) #t) (make-hash-table) 'foo 'bar))
|
||||
)
|
||||
|
||||
|
||||
;;;
|
||||
;;; hash-count
|
||||
;;;
|
||||
|
||||
(with-test-prefix "hash-count"
|
||||
(let ((table (make-hash-table)))
|
||||
(hashq-set! table 'foo "bar")
|
||||
(hashq-set! table 'braz "zonk")
|
||||
(hashq-create-handle! table 'frob #f)
|
||||
|
||||
(pass-if (equal? 3 (hash-count (const #t) table)))
|
||||
|
||||
(pass-if (equal? 2 (hash-count (lambda (k v)
|
||||
(string? v)) table)))))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue