Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,12 @@ extension Array: SectionedDataSourceChangesetConvertible {
}
}

extension Array2D: SectionedDataSourceChangesetConvertible {
public var asSectionedDataSourceChangeset: OrderedCollectionChangeset<Array2D> {
return OrderedCollectionChangeset(collection: self, patch: [])
}
}

extension OrderedCollectionChangeset: SectionedDataSourceChangeset where Diff.Index: SectionedDataIndexPathConvertable, Collection: SectionedDataSourceProtocol {}

extension OrderedCollectionChangeset: SectionedDataSourceChangesetConvertible where Diff.Index: SectionedDataIndexPathConvertable, Collection: SectionedDataSourceProtocol {
Expand Down
34 changes: 34 additions & 0 deletions Sources/Bond/Data Structures/Array2D.swift
Original file line number Diff line number Diff line change
Expand Up @@ -219,3 +219,37 @@ extension Array2D {
}
}
}

// MARK: - Sequence conformance

extension Array2D: Swift.Sequence {
public typealias Iterator = IndexingIterator<[Array2D.Section]>

public func makeIterator() -> Iterator {
return sections.makeIterator()
}
}

// MARK: - Collection conformance

extension Array2D: Collection {
public typealias Index = Int

public var startIndex: Index {
return sections.startIndex
}

public var endIndex: Index {
return sections.endIndex
}

public subscript(position: Index) -> Iterator.Element {
precondition(indices.contains(position), "out of bounds")
let element = sections[position]
return element
}

public func index(after i: Index) -> Index {
return sections.index(after: i)
}
}