Function HASH-TABLE-COUNT
hash-table-count hash-table => count
hash-table - ハッシュテーブル
count - 非負の整数
hash-tableのエントリーの数を返却します。 もしhash-tableがちょうど作成されたときか、 新しい状態にクリアされた(clrhashをご確認ください)ときは、 エントリー数は0です。
(setq table (make-hash-table)) => #<HASH-TABLE EQL 0/120 32115135>
(hash-table-count table) => 0
(setf (gethash 57 table) "fifty-seven") => "fifty-seven"
(hash-table-count table) => 1
(dotimes (i 100) (setf (gethash i table) i)) => NIL
(hash-table-count table) => 100なし。
clrhash, remhash, setfのgethash
なし。
下記の関係は機能的には正しいですが、 実際のhash-table-countはおそらくもっと高速です。
(hash-table-count table) ==
(loop for value being the hash-values of table count t) ==
(let ((total 0))
(maphash #'(lambda (key value)
(declare (ignore key value))
(incf total))
table)
total)