サンプリング

public struct Sampling<Base: Collection, Selection: Collection>
where Selection.Element == Base.Index
extension Sampling: SamplingProtocol
extension Sampling: Collection
extension Sampling: BidirectionalCollection
  where Selection: BidirectionalCollection
extension Sampling: RandomAccessCollection
  where Selection: RandomAccessCollection

何らかの基本コレクションから、指定された順序で要素を遅延選択します。

  • baseselectionからインスタンスを作成します。

    宣言

    public init(base: Base, selection: Selection)
  • 宣言

    public typealias Element = Base.Element
  • インスタンスがself内の位置を表す型。

    宣言

    public typealias Index = Selection.Index
  • 最初の要素の位置。

    宣言

    public var startIndex: Index { get }
  • 最後の要素の 1 つ後の位置。

    宣言

    public var endIndex: Index { get }
  • iの要素を返します。

    宣言

    public subscript(i: Index) -> Element { get }
  • iの後の位置を返します。

    宣言

    public func index(after i: Index) -> Index
  • start endに変換するために必要な前進ステップ数を返します。

    負の結果は、 end < startであることを示します。

    宣言

    public func distance(from start: Index, to end: Index) -> Int
  • iからn番目の位置を返します。

    宣言

    public func index(_ i: Index, offsetBy n: Int) -> Index
  • limitを渡す必要がない限り、 distanceによってオフセットされたiを返します。その場合、 nilが返されます。

    宣言

    public func index(
      _ i: Index, offsetBy distance: Int, limitedBy limit: Index
    ) -> Index?
`Selection`: `BidirectionalCollection` で利用可能