Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
class OverlapFreePatternDetectorConenctor (
private val first: PatternDetector,
private val second: PatternDetector): PatternDetector {
override fun findPatterns(data: List<Weight>): List<Pattern> {
val firstPatterns = first(data)
val secondPatterns = second(data)
val overlaps = overlaps(firstPatterns, secondPatterns)
val firstPatternsAdjusted = firstPatterns
.asSequence()
.map { adjustForOverlaps(it, overlaps) }
.filter(Pattern::isNotEmpty)
.toList()
val secondPatternsAdjusted = secondPatterns
.asSequence()
.map { adjustForOverlaps(it, overlaps) }
.filter(Pattern::isNotEmpty)
.toList()
return firstPatternsAdjusted + secondPatternsAdjusted
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment