Factor Documentation
|
Home
|
Glossary
|
Search
factorcode.org
cardinality ( set -- n )
Factor documentation
>
Factor handbook
>
The language
>
Collections
>
Sets
>
Operations on sets
Prev:
members ( set -- seq )
Next:
adjoin ( elt set -- )
Vocabulary
sets
Inputs and outputs
set
a
set
n
a non-negative integer
Word description
Returns the number of elements in the set. All sets support this operation.
Definition
IN:
sets
GENERIC:
cardinality
( set -- n )
Methods
USING:
accessors
bit-sets
math.bitwise
sets
;
M:
bit-set
cardinality
table>>
bit-count
;
USING:
kernel
sets
;
M:
f
cardinality
drop
0
;
USING:
accessors
hash-sets
kernel
math
sets
;
M:
hash-set
cardinality
[
count>>
]
[
deleted>>
]
bi
-
;
inline
USING:
sequences
sets
;
M:
sequence
cardinality
fast-set
cardinality
;
USING:
sequences
sets
;
M:
set
cardinality
members
length
;
USING:
accessors
hash-sets.wrapped
sets
;
M:
wrapped-hash-set
cardinality
underlying>>
cardinality
;
inline