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

54: cell division issue in cell rendering #65

Closed
wants to merge 1 commit into from
Closed

54: cell division issue in cell rendering #65

wants to merge 1 commit into from

Conversation

btxsqdr
Copy link

@btxsqdr btxsqdr commented Apr 24, 2019

See issue details here: #54

From
for currentY in stride(from: minY, to: maxY, by: 1) {

To
for currentY in stride(from: minY, to: maxY, by: 0.1) {

Because if minY/maxY diff is < 1, stride by 1 will skip some items if too close, therefore 0.1. It is a division issue, apparently.

@btxsqdr btxsqdr mentioned this pull request Apr 24, 2019
@btxsqdr btxsqdr changed the title 54: if minY/maxY diff is < 1, stride by 1 will skip some items if too… 54: cell division issue in cell rendering Apr 24, 2019
@zjfjack
Copy link
Owner

zjfjack commented Apr 28, 2019

I will reject this pull request and use a new algorithm mentioned in #54 to resolve this issue.

I will try to push the new version as soon as possible, some performance, testing, comments need to be done as well. Thanks

Swift algorithm code is showing below:

func maxOverlapIntervalCount(startY: [CGFloat], endY: [CGFloat]) -> Int {
    var maxOverlap = 0, currentOverlap = 0
    let sortedStartY = startY.sorted(), sortedEndY = endY.sorted()
        
    var i = 0, j = 0
    while i < sortedStartY.count && j < sortedEndY.count {
        if sortedStartY[i] < sortedEndY[j] {
            currentOverlap += 1
            maxOverlap = max(maxOverlap, currentOverlap)
            i += 1
        } else {
            currentOverlap -= 1
            j += 1
        }
    }
    return maxOverlap
}

@zjfjack zjfjack closed this Apr 28, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants