summaryrefslogtreecommitdiff
path: root/src/main
diff options
context:
space:
mode:
authorEdoardo La Greca2025-08-07 18:16:18 +0200
committerEdoardo La Greca2025-08-07 18:16:18 +0200
commit39fb93f4d6601f046ac3678fa9a994b0d60bc163 (patch)
tree0b5bffbe5196110f28ea1a270f6d795caaa449be /src/main
parent7b49a4c587eaaee3d071ad12aaeb54ac302d06fa (diff)
change methods in PathInfo
Diffstat (limited to 'src/main')
-rw-r--r--src/main/kotlin/PathInfo.kt41
1 files 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<String>): UInt? {
- return this.paths.find { x -> x.path == path }?.fid
- }
+ fun findByPath(path: List<String>): 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<String>): 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<String>? {
- return this.paths.find { x -> x.fid == fid }?.path
+ fun findByQID(qid: QID): Path? {
+ return this.paths.find { x -> x.qid == qid }
}
/**