Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use a stock iterator instead of a custom one. #3891

Merged
merged 1 commit into from
Mar 9, 2019
Merged
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
20 changes: 8 additions & 12 deletions Source/Charts/Renderers/BarLineScatterCandleBubbleRenderer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -102,22 +102,18 @@ extension BarLineScatterCandleBubbleRenderer.XBounds: RangeExpression {

extension BarLineScatterCandleBubbleRenderer.XBounds: Sequence {
public struct Iterator: IteratorProtocol {
private let bounds: BarLineScatterCandleBubbleRenderer.XBounds
private var value: Int

fileprivate init(bounds: BarLineScatterCandleBubbleRenderer.XBounds) {
self.bounds = bounds
self.value = bounds.min
private var iterator: IndexingIterator<ClosedRange<Int>>

fileprivate init(min: Int, max: Int) {
self.iterator = (min...max).makeIterator()
}

public mutating func next() -> Int? {
guard value < bounds.max else { return nil }
value += 1
return value
return self.iterator.next()
}
}

public func makeIterator() -> Iterator {
return Iterator(bounds: self)
return Iterator(min: self.min, max: self.max)
}
}