Instance Property インスタンスプロパティ

count

The number of elements in the collection. コレクションの要素の数を返します。

Declaration 宣言

var count: Int { get }

Discussion 議論

To check whether a collection is empty, use its isEmpty property instead of comparing count to zero. Unless the collection guarantees random-access performance, calculating count can be an O(n) operation. あるコレクションが空かどうか調べるには、それのisEmptyプロパティを使ってください、countをゼロと比較するのでなく。そのコレクションが無作為アクセス性能を保証しない限り、countの算出は、O(n)演算であるはずです。

Complexity: O(1) if the collection conforms to RandomAccessCollection; otherwise, O(n), where n is the length of the collection. 計算量:コレクションがRandomAccessCollectionに準拠するならば、O(1);そうでなければ、O(n)、そこでnはコレクションの長さです。