mirror of
https://github.com/GayPizzaSpecifications/darwin-apk.git
synced 2025-08-03 21:41:31 +00:00
basic package graph implemented
This commit is contained in:
35
Sources/apk/Graph/ApkPackageGraphNode.swift
Normal file
35
Sources/apk/Graph/ApkPackageGraphNode.swift
Normal file
@ -0,0 +1,35 @@
|
||||
/*
|
||||
* darwin-apk © 2024 Gay Pizza Specifications
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
import Foundation
|
||||
|
||||
class ApkPackageGraphNode {
|
||||
private weak var graph: ApkPackageGraph!
|
||||
let package: ApkIndexPackage
|
||||
|
||||
//private var _parents = NSHashTable<ApkPackageGraphNode>.weakObjects()
|
||||
//private var _children = NSHashTable<ApkPackageGraphNode>.weakObjects()
|
||||
var parents = [ApkIndexRequirementRef]()
|
||||
var children: [ApkIndexRequirementRef]
|
||||
|
||||
internal init(package: ApkIndexPackage, children: [ApkIndexRequirementRef]) {
|
||||
self.package = package
|
||||
self.children = children
|
||||
}
|
||||
}
|
||||
|
||||
extension ApkPackageGraphNode: CustomStringConvertible {
|
||||
var description: String {
|
||||
var result = "node[\(self.package.name)]"
|
||||
if !self.parents.isEmpty {
|
||||
result += ", parents[\(self.parents.lazy.map(\.description).joined(separator: ", "))]"
|
||||
}
|
||||
if !self.children.isEmpty {
|
||||
result += ", children[\(self.children.lazy.map(\.description).joined(separator: ", "))]"
|
||||
|
||||
}
|
||||
return result
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user