From 18612877033b11fee938c3196adceb01762f5702 Mon Sep 17 00:00:00 2001 From: Heiko Schaefer Date: Mon, 17 Jul 2023 12:40:33 +0200 Subject: [PATCH] Move WoT algorithm implementation to the query package --- .../org/pgpainless/wot/dijkstra/package-info.java | 5 ----- .../pgpainless/wot/{dijkstra => query}/Cost.kt | 6 +----- .../wot/{dijkstra => query}/ForwardPointer.kt | 6 +----- .../wot/{dijkstra => query}/PairPriorityQueue.kt | 8 ++------ .../pgpainless/wot/{dijkstra => query}/Query.kt | 15 ++++++--------- .../wot/{dijkstra => query}/WotNetwork.kt | 7 +------ .../wot/{dijkstra => query}/CostTest.kt | 3 ++- .../{dijkstra => query}/PairPriorityQueueTest.kt | 2 +- 8 files changed, 14 insertions(+), 38 deletions(-) delete mode 100644 wot-dijkstra/src/main/kotlin/org/pgpainless/wot/dijkstra/package-info.java rename wot-dijkstra/src/main/kotlin/org/pgpainless/wot/{dijkstra => query}/Cost.kt (88%) rename wot-dijkstra/src/main/kotlin/org/pgpainless/wot/{dijkstra => query}/ForwardPointer.kt (69%) rename wot-dijkstra/src/main/kotlin/org/pgpainless/wot/{dijkstra => query}/PairPriorityQueue.kt (88%) rename wot-dijkstra/src/main/kotlin/org/pgpainless/wot/{dijkstra => query}/Query.kt (98%) rename wot-dijkstra/src/main/kotlin/org/pgpainless/wot/{dijkstra => query}/WotNetwork.kt (96%) rename wot-dijkstra/src/test/kotlin/org/pgpainless/wot/{dijkstra => query}/CostTest.kt (90%) rename wot-dijkstra/src/test/kotlin/org/pgpainless/wot/{dijkstra => query}/PairPriorityQueueTest.kt (99%) diff --git a/wot-dijkstra/src/main/kotlin/org/pgpainless/wot/dijkstra/package-info.java b/wot-dijkstra/src/main/kotlin/org/pgpainless/wot/dijkstra/package-info.java deleted file mode 100644 index 7cbce840..00000000 --- a/wot-dijkstra/src/main/kotlin/org/pgpainless/wot/dijkstra/package-info.java +++ /dev/null @@ -1,5 +0,0 @@ -// SPDX-FileCopyrightText: 2023 Heiko Schaefer -// -// SPDX-License-Identifier: Apache-2.0 - -package org.pgpainless.wot.dijkstra; \ No newline at end of file diff --git a/wot-dijkstra/src/main/kotlin/org/pgpainless/wot/dijkstra/Cost.kt b/wot-dijkstra/src/main/kotlin/org/pgpainless/wot/query/Cost.kt similarity index 88% rename from wot-dijkstra/src/main/kotlin/org/pgpainless/wot/dijkstra/Cost.kt rename to wot-dijkstra/src/main/kotlin/org/pgpainless/wot/query/Cost.kt index c06bcf81..c10d58f0 100644 --- a/wot-dijkstra/src/main/kotlin/org/pgpainless/wot/dijkstra/Cost.kt +++ b/wot-dijkstra/src/main/kotlin/org/pgpainless/wot/query/Cost.kt @@ -1,8 +1,4 @@ -// SPDX-FileCopyrightText: 2023 Heiko Schaefer -// -// SPDX-License-Identifier: Apache-2.0 - -package org.pgpainless.wot.dijkstra +package org.pgpainless.wot.query import kotlin.math.min diff --git a/wot-dijkstra/src/main/kotlin/org/pgpainless/wot/dijkstra/ForwardPointer.kt b/wot-dijkstra/src/main/kotlin/org/pgpainless/wot/query/ForwardPointer.kt similarity index 69% rename from wot-dijkstra/src/main/kotlin/org/pgpainless/wot/dijkstra/ForwardPointer.kt rename to wot-dijkstra/src/main/kotlin/org/pgpainless/wot/query/ForwardPointer.kt index bd317bef..e87baf6a 100644 --- a/wot-dijkstra/src/main/kotlin/org/pgpainless/wot/dijkstra/ForwardPointer.kt +++ b/wot-dijkstra/src/main/kotlin/org/pgpainless/wot/query/ForwardPointer.kt @@ -1,8 +1,4 @@ -// SPDX-FileCopyrightText: 2023 Heiko Schaefer -// -// SPDX-License-Identifier: Apache-2.0 - -package org.pgpainless.wot.dijkstra +package org.pgpainless.wot.query import org.pgpainless.wot.network.EdgeComponent diff --git a/wot-dijkstra/src/main/kotlin/org/pgpainless/wot/dijkstra/PairPriorityQueue.kt b/wot-dijkstra/src/main/kotlin/org/pgpainless/wot/query/PairPriorityQueue.kt similarity index 88% rename from wot-dijkstra/src/main/kotlin/org/pgpainless/wot/dijkstra/PairPriorityQueue.kt rename to wot-dijkstra/src/main/kotlin/org/pgpainless/wot/query/PairPriorityQueue.kt index 3e1c7eef..a4be8514 100644 --- a/wot-dijkstra/src/main/kotlin/org/pgpainless/wot/dijkstra/PairPriorityQueue.kt +++ b/wot-dijkstra/src/main/kotlin/org/pgpainless/wot/query/PairPriorityQueue.kt @@ -1,10 +1,6 @@ -// SPDX-FileCopyrightText: 2023 Heiko Schaefer -// -// SPDX-License-Identifier: Apache-2.0 +package org.pgpainless.wot.query -package org.pgpainless.wot.dijkstra - -import java.util.PriorityQueue +import java.util.* /** * A de-duplicating min-priority queue for key-value pairs. diff --git a/wot-dijkstra/src/main/kotlin/org/pgpainless/wot/dijkstra/Query.kt b/wot-dijkstra/src/main/kotlin/org/pgpainless/wot/query/Query.kt similarity index 98% rename from wot-dijkstra/src/main/kotlin/org/pgpainless/wot/dijkstra/Query.kt rename to wot-dijkstra/src/main/kotlin/org/pgpainless/wot/query/Query.kt index e38a5ac9..b33681c7 100644 --- a/wot-dijkstra/src/main/kotlin/org/pgpainless/wot/dijkstra/Query.kt +++ b/wot-dijkstra/src/main/kotlin/org/pgpainless/wot/query/Query.kt @@ -1,12 +1,9 @@ -// SPDX-FileCopyrightText: 2023 Heiko Schaefer -// -// SPDX-License-Identifier: Apache-2.0 +package org.pgpainless.wot.query -package org.pgpainless.wot.dijkstra - -import org.pgpainless.wot.network.* -import org.pgpainless.wot.query.Path -import org.pgpainless.wot.query.Paths +import org.pgpainless.wot.network.Fingerprint +import org.pgpainless.wot.network.Network +import org.pgpainless.wot.network.Node +import org.pgpainless.wot.network.Roots import org.slf4j.Logger import org.slf4j.LoggerFactory import kotlin.math.max @@ -289,4 +286,4 @@ class Query(private val rawNetwork: Network, return p } -} +} \ No newline at end of file diff --git a/wot-dijkstra/src/main/kotlin/org/pgpainless/wot/dijkstra/WotNetwork.kt b/wot-dijkstra/src/main/kotlin/org/pgpainless/wot/query/WotNetwork.kt similarity index 96% rename from wot-dijkstra/src/main/kotlin/org/pgpainless/wot/dijkstra/WotNetwork.kt rename to wot-dijkstra/src/main/kotlin/org/pgpainless/wot/query/WotNetwork.kt index 2b8e0736..3c832d76 100644 --- a/wot-dijkstra/src/main/kotlin/org/pgpainless/wot/dijkstra/WotNetwork.kt +++ b/wot-dijkstra/src/main/kotlin/org/pgpainless/wot/query/WotNetwork.kt @@ -1,11 +1,6 @@ -// SPDX-FileCopyrightText: 2023 Heiko Schaefer -// -// SPDX-License-Identifier: Apache-2.0 - -package org.pgpainless.wot.dijkstra +package org.pgpainless.wot.query import org.pgpainless.wot.network.* -import org.pgpainless.wot.query.Path /** * A wrapper for `Network` that performs the following functions: diff --git a/wot-dijkstra/src/test/kotlin/org/pgpainless/wot/dijkstra/CostTest.kt b/wot-dijkstra/src/test/kotlin/org/pgpainless/wot/query/CostTest.kt similarity index 90% rename from wot-dijkstra/src/test/kotlin/org/pgpainless/wot/dijkstra/CostTest.kt rename to wot-dijkstra/src/test/kotlin/org/pgpainless/wot/query/CostTest.kt index a1db56d8..ce1a37cc 100644 --- a/wot-dijkstra/src/test/kotlin/org/pgpainless/wot/dijkstra/CostTest.kt +++ b/wot-dijkstra/src/test/kotlin/org/pgpainless/wot/query/CostTest.kt @@ -2,8 +2,9 @@ // // SPDX-License-Identifier: Apache-2.0 -package org.pgpainless.wot.dijkstra +package org.pgpainless.wot.query +import org.pgpainless.wot.query.Cost import kotlin.test.Test class CostTest { diff --git a/wot-dijkstra/src/test/kotlin/org/pgpainless/wot/dijkstra/PairPriorityQueueTest.kt b/wot-dijkstra/src/test/kotlin/org/pgpainless/wot/query/PairPriorityQueueTest.kt similarity index 99% rename from wot-dijkstra/src/test/kotlin/org/pgpainless/wot/dijkstra/PairPriorityQueueTest.kt rename to wot-dijkstra/src/test/kotlin/org/pgpainless/wot/query/PairPriorityQueueTest.kt index 9e384baf..a882c6a2 100644 --- a/wot-dijkstra/src/test/kotlin/org/pgpainless/wot/dijkstra/PairPriorityQueueTest.kt +++ b/wot-dijkstra/src/test/kotlin/org/pgpainless/wot/query/PairPriorityQueueTest.kt @@ -2,7 +2,7 @@ // // SPDX-License-Identifier: Apache-2.0 -package org.pgpainless.wot.dijkstra +package org.pgpainless.wot.query import kotlin.test.Test import kotlin.test.assertEquals