샘플링

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 }
  • 마지막 요소 하나 다음의 위치입니다.

    선언

    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?
'선택': '양방향 수집'에서 사용 가능