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. 計算量:O(1)、もしコレクションがRandomAccessCollectionに準拠するならば;そうでなければ、O(n)、そこでnはコレクションの長さです。