hash-count
This commit is contained in:
parent
c02c40f93e
commit
4c4d4437b8
|
@ -109,7 +109,8 @@
|
|||
'hash-remove!
|
||||
'hash-remove
|
||||
'equal-hash-code
|
||||
|
||||
'hash-count
|
||||
|
||||
'string-copy
|
||||
))
|
||||
(define-predicate KernelPrimitiveName? KernelPrimitiveName)
|
||||
|
|
|
@ -137,6 +137,10 @@
|
|||
return new WhalesongHashtable(this.type, this.hash_function, this.equality_function, this.hash.clone());
|
||||
};
|
||||
|
||||
WhalesongHashtable.prototype.size = function() {
|
||||
return this.hash.size();
|
||||
};
|
||||
|
||||
WhalesongHashtable.prototype.toWrittenString = function (cache) {
|
||||
var keys = this.hash.keys();
|
||||
var ret = [], i;
|
||||
|
@ -251,6 +255,11 @@
|
|||
this.map = map;
|
||||
};
|
||||
|
||||
WhalesongImmutableHashtable.prototype.size = function() {
|
||||
return this.map.items().length;
|
||||
};
|
||||
|
||||
|
||||
WhalesongImmutableHashtable.prototype.toWrittenString = function (cache) {
|
||||
var items = this.map.items();
|
||||
var ret = [], i;
|
||||
|
|
|
@ -2578,6 +2578,13 @@
|
|||
var hash = checkMutableHash(M, 'hash-copy', 0);
|
||||
return hash.clone();
|
||||
});
|
||||
|
||||
installPrimitiveProcedure(
|
||||
'hash-count',
|
||||
1,
|
||||
function(M) {
|
||||
return checkHash(M, 'hash-count', 0).size();
|
||||
});
|
||||
|
||||
installPrimitiveProcedure(
|
||||
'hash',
|
||||
|
|
|
@ -168,6 +168,7 @@
|
|||
hash-remove!
|
||||
hash-remove
|
||||
equal-hash-code
|
||||
hash-count
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -55,3 +55,6 @@ true
|
|||
|
||||
A
|
||||
alphabet
|
||||
|
||||
1
|
||||
2
|
||||
|
|
|
@ -132,3 +132,9 @@
|
|||
(hash-set! h2 'a "alphabet")
|
||||
(displayln (hash-ref h1 'a))
|
||||
(displayln (hash-ref h2 'a)))
|
||||
|
||||
|
||||
(newline)
|
||||
(hash-count (make-hash '((a . a))))
|
||||
(hash-count (make-immutable-hash '((b . b)
|
||||
(c . d))))
|
Loading…
Reference in New Issue
Block a user