From 7341ead2aade10ea1b833e94275277658741883a Mon Sep 17 00:00:00 2001 From: Edoardo La Greca Date: Mon, 18 Aug 2025 21:09:11 +0200 Subject: switch to multi-module project structure --- src/main/kotlin/PathInfo.kt | 93 --------------------------------------------- 1 file changed, 93 deletions(-) delete mode 100644 src/main/kotlin/PathInfo.kt (limited to 'src/main/kotlin/PathInfo.kt') diff --git a/src/main/kotlin/PathInfo.kt b/src/main/kotlin/PathInfo.kt deleted file mode 100644 index 2aee406..0000000 --- a/src/main/kotlin/PathInfo.kt +++ /dev/null @@ -1,93 +0,0 @@ -/** - * This class holds all info about paths, their FIDs, and their QIDs. - */ -class PathInfo() { - private val paths: MutableSet = mutableSetOf() - - /** - * Information about a path. Each FID maps to one path but not all paths have FIDs (injective). On the other hand, - * one QID can be shared with different paths and FIDs. - * - * FIDs are optional because some R-messages only return QIDs for certain files (e.g. walk). - * - * @param path The path. - * @param fid The optional FID associated with the path. - * @param qid The QID associated with the path. - */ - data class Path(val path: List, val fid: UInt?, val qid: QID) - - /** - * Add a path. - */ - fun addPath(path: Path) { - this.paths.add(path) - } - - /** - * Add a QID to an existing FID. Do nothing if the given FID does not exist. - */ - fun addQIDToFID(fid: UInt, qid: QID) { - findByFID(fid)?.qid = qid - } - - /** - * Remove a FID. - */ - fun removeFID(fid: UInt) { - this.paths.removeIf { x -> x.fid == fid } - } - - fun find(predicate: (Path) -> Boolean) = this.paths.find(predicate) - - /** - * Find [Path] object by path. - * - * @param path The path to search for. - * @return A path object if [path] exists, or null otherwise. - */ - fun findByPath(path: List): Path? { - return this.paths.find { x -> x.path == path } - } - - /** - * Find [Path] object by FID. - * - * @param fid The FID to search for. - * @return A path object if [fid] exists, or null otherwise. - */ - fun findByFID(fid: UInt): Path? { - return this.paths.find { x -> x.fid == fid } - } - - /** - * Find [Path] object by QID. - * - * @param qid The path to search for. - * @return A path object if [qid] exists, or null otherwise. - */ - fun findByQID(qid: QID): Path? { - return this.paths.find { x -> x.qid == qid } - } - - /** - * Retrieve all paths - */ - fun getAllPaths(): Set { - return this.paths.toSet() - } - - /** - * Generate a new FID which is not already in use. - * - * @return The new FID. - * @throws IllegalStateException if there is no available FID. - */ - fun genFID(): UInt { - for (newFid in 0u..UInt.MAX_VALUE) { - if (findByFID(newFid) == null) { - return newFid - } - } - throw IllegalStateException() - } -} \ No newline at end of file -- cgit v1.2.3