From 39fb93f4d6601f046ac3678fa9a994b0d60bc163 Mon Sep 17 00:00:00 2001 From: Edoardo La Greca Date: Thu, 7 Aug 2025 18:16:18 +0200 Subject: change methods in PathInfo --- src/main/kotlin/PathInfo.kt | 41 +++++++++++++++++++++++++---------------- 1 file changed, 25 insertions(+), 16 deletions(-) diff --git a/src/main/kotlin/PathInfo.kt b/src/main/kotlin/PathInfo.kt index c9ff29e..4981662 100644 --- a/src/main/kotlin/PathInfo.kt +++ b/src/main/kotlin/PathInfo.kt @@ -24,33 +24,42 @@ class PathInfo() { } /** - * Find the FID associated with a path. + * 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 find the FID of. - * @return The FID if [path] has an associated FID, or null otherwise. + * @param path The path to search for. + * @return A path object if [path] exists, or null otherwise. */ - fun findFIDByPath(path: List): UInt? { - return this.paths.find { x -> x.path == path }?.fid - } + fun findByPath(path: List): Path? { + return this.paths.find { x -> x.path == path } + } /** - * Find the QID associated to a path. + * Find [Path] object by FID. * - * @param path The path to find the QID of. - * @return The QID if [path] could be found, or null otherwise. + * @param fid The FID to search for. + * @return A path object if [fid] exists, or null otherwise. */ - fun findQIDByPath(path: List): QID? { - return this.paths.find { x -> x.path == path }?.qid + fun findByFID(fid: UInt): Path? { + return this.paths.find { x -> x.fid == fid } } /** - * Find the path associated to a FID. + * Find [Path] object by QID. * - * @param fid The FID to find the path of. - * @return The path if [fid] could be found, or null otherwise. + * @param qid The path to search for. + * @return A path object if [qid] exists, or null otherwise. */ - fun findPathByFID(fid: UInt): List? { - return this.paths.find { x -> x.fid == fid }?.path + fun findByQID(qid: QID): Path? { + return this.paths.find { x -> x.qid == qid } } /** -- cgit v1.2.3