From 7a72bcbe8b24734ac7c1d622c8877812152f362d Mon Sep 17 00:00:00 2001 From: Daniel Lin Date: Sun, 22 Dec 2024 18:27:58 -0500 Subject: [PATCH] Bump Gradle from 8.11.1 to 8.12 in /kt Release notes: https://docs.gradle.org/8.12/release-notes.html --- .../ephemient/aoc2024/CommonPriorityQueue.kt | 3 ++ .../github/ephemient/aoc2024/PriorityQueue.kt | 3 ++ .../github/ephemient/aoc2024/PriorityQueue.kt | 46 +------------------ kt/gradle.properties | 2 + kt/gradle/wrapper/gradle-wrapper.properties | 2 +- kt/gradlew | 3 +- 6 files changed, 11 insertions(+), 48 deletions(-) diff --git a/kt/aoc2024-lib/src/commonMain/kotlin/com/github/ephemient/aoc2024/CommonPriorityQueue.kt b/kt/aoc2024-lib/src/commonMain/kotlin/com/github/ephemient/aoc2024/CommonPriorityQueue.kt index 27acf660..015eccd9 100644 --- a/kt/aoc2024-lib/src/commonMain/kotlin/com/github/ephemient/aoc2024/CommonPriorityQueue.kt +++ b/kt/aoc2024-lib/src/commonMain/kotlin/com/github/ephemient/aoc2024/CommonPriorityQueue.kt @@ -20,6 +20,9 @@ internal class CommonPriorityQueue(private val comparator: Comparator : Iterable { fun add(element: E): Boolean + @Throws(NoSuchElementException::class) + fun peek(): E + @Throws(NoSuchElementException::class) fun remove(): E } diff --git a/kt/aoc2024-lib/src/nonJvmMain/kotlin/com/github/ephemient/aoc2024/PriorityQueue.kt b/kt/aoc2024-lib/src/nonJvmMain/kotlin/com/github/ephemient/aoc2024/PriorityQueue.kt index 52e2e578..deac709e 100644 --- a/kt/aoc2024-lib/src/nonJvmMain/kotlin/com/github/ephemient/aoc2024/PriorityQueue.kt +++ b/kt/aoc2024-lib/src/nonJvmMain/kotlin/com/github/ephemient/aoc2024/PriorityQueue.kt @@ -1,48 +1,4 @@ package com.github.ephemient.aoc2024 -internal class PriorityQueueImpl(private val comparator: Comparator) : PriorityQueue { - private val storage = mutableListOf() - - override fun isEmpty(): Boolean = storage.isEmpty() - - override fun add(element: E): Boolean { - storage.add(element) - var i = storage.lastIndex - while (i > 0) { - val j = (i - 1) / 2 - val a = storage[j] - val b = storage[i] - if (comparator.compare(a, b) <= 0) break - storage[i] = a - storage[j] = b - i = j - } - return true - } - - @Suppress("NestedBlockDepth") - @Throws(NoSuchElementException::class) - override fun remove(): E { - val first = storage.first() - val last = storage.removeLast() - if (storage.isNotEmpty()) { - storage[0] = last - var i = 0 - while (2 * i + 2 < storage.size) { - val j = if (comparator.compare(storage[2 * i + 1], storage[2 * i + 2]) < 0) 2 * i + 1 else 2 * i + 2 - if (comparator.compare(storage[i], storage[j]) <= 0) break - storage[i] = storage[j].also { storage[j] = storage[i] } - i = j - } - if (2 * i + 1 == storage.lastIndex && comparator.compare(storage[i], storage.last()) > 0) { - storage[i] = storage.last().also { storage[storage.lastIndex] = storage[i] } - } - } - return first - } - - override fun iterator(): Iterator = storage.iterator() -} - actual fun PriorityQueue(comparator: Comparator): PriorityQueue = - PriorityQueueImpl(comparator) + CommonPriorityQueue(comparator) diff --git a/kt/gradle.properties b/kt/gradle.properties index 123fca04..3a3942f5 100644 --- a/kt/gradle.properties +++ b/kt/gradle.properties @@ -1,5 +1,7 @@ kotlin.code.style=official +kotlin.native.enableKlibsCrossCompilation=true org.gradle.caching=true org.gradle.configuration-cache=true +org.gradle.configuration-cache.parallel=true org.gradle.jvmargs=-Xmx2g -XX:MaxMetaspaceSize=512m -XX:+UseParallelGC -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 org.gradle.parallel=true diff --git a/kt/gradle/wrapper/gradle-wrapper.properties b/kt/gradle/wrapper/gradle-wrapper.properties index e2847c82..cea7a793 100644 --- a/kt/gradle/wrapper/gradle-wrapper.properties +++ b/kt/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.11.1-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.12-bin.zip networkTimeout=10000 validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME diff --git a/kt/gradlew b/kt/gradlew index f5feea6d..f3b75f3b 100755 --- a/kt/gradlew +++ b/kt/gradlew @@ -86,8 +86,7 @@ done # shellcheck disable=SC2034 APP_BASE_NAME=${0##*/} # Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) -APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s -' "$PWD" ) || exit +APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD=maximum