Skip to content

Commit

Permalink
Use recommended code style for Kotlin.
Browse files Browse the repository at this point in the history
  • Loading branch information
io7m committed Mar 20, 2024
1 parent 9f9b9be commit 5b883da
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@ package com.io7m.kabstand.core
import java.math.BigInteger

data class IntervalB(
val lower: BigInteger,
val upper: BigInteger
val lower : BigInteger, val upper : BigInteger
) : IntervalType<BigInteger> {

init {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ data class IntervalD(
}

override fun upperMaximum(
other : IntervalType<Double>) : IntervalType<Double> {
other : IntervalType<Double>
) : IntervalType<Double> {
return IntervalD(
this.lower,
Math.max(this.upper, other.upper())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
package com.io7m.kabstand.core

data class IntervalI(
val lower: Int,
val upper: Int
val lower : Int,
val upper : Int
) : IntervalType<Int> {

init {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,17 @@
package com.io7m.kabstand.core

data class IntervalL(
val lower: Long,
val upper: Long
val lower : Long,
val upper : Long
) : IntervalType<Long> {

init {
check(upper >= lower) { "Upper $upper must be >= lower $lower " }
}

override fun overlaps(
other : IntervalType<Long>) : Boolean {
other : IntervalType<Long>
) : Boolean {
return (this.lower <= other.upper() && other.lower() <= this.upper)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -181,14 +181,24 @@ class IntervalTree<S : Comparable<S>> private constructor(
when (current.left!!.balanceFactor()) {
RIGHT_HEAVY,
BALANCED_LEANING_RIGHT -> {
this.publish(IntervalTreeChangeType.Balanced("RL", current.interval))
this.publish(
IntervalTreeChangeType.Balanced(
"RL",
current.interval
)
)
this.rotateRL(current)
}

LEFT_HEAVY,
BALANCED,
BALANCED_LEANING_LEFT -> {
this.publish(IntervalTreeChangeType.Balanced("RR", current.interval))
this.publish(
IntervalTreeChangeType.Balanced(
"RR",
current.interval
)
)
this.rotateRR(current)
}
}
Expand All @@ -198,14 +208,24 @@ class IntervalTree<S : Comparable<S>> private constructor(
when (current.right!!.balanceFactor()) {
LEFT_HEAVY,
BALANCED_LEANING_LEFT -> {
this.publish(IntervalTreeChangeType.Balanced("LR", current.interval))
this.publish(
IntervalTreeChangeType.Balanced(
"LR",
current.interval
)
)
this.rotateLR(current)
}

RIGHT_HEAVY,
BALANCED,
BALANCED_LEANING_RIGHT -> {
this.publish(IntervalTreeChangeType.Balanced("LL", current.interval))
this.publish(
IntervalTreeChangeType.Balanced(
"LL",
current.interval
)
)
this.rotateLL(current)
}
}
Expand Down Expand Up @@ -353,12 +373,14 @@ class IntervalTree<S : Comparable<S>> private constructor(

IntervalComparison.LESS_THAN -> {
current.takeOwnershipLeft(
this.create(current, current.left, interval))
this.create(current, current.left, interval)
)
}

IntervalComparison.MORE_THAN -> {
current.takeOwnershipRight(
this.create(current, current.right, interval))
this.create(current, current.right, interval)
)
}
}

Expand Down

0 comments on commit 5b883da

Please sign in to comment.