mirror of
https://github.com/GayPizzaSpecifications/darwin-apk.git
synced 2025-08-05 06:21:31 +00:00
49 lines
1.1 KiB
Swift
49 lines
1.1 KiB
Swift
/*
|
|
* darwin-apk © 2024, 2025 Gay Pizza Specifications
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
*/
|
|
|
|
import Foundation
|
|
|
|
public class ApkPackageGraphNode {
|
|
public let packageID: ApkIndex.Index
|
|
public var parentIDs = [ApkIndex.Index]()
|
|
public var children: [ChildRef]
|
|
|
|
@inlinable public var isShallow: Bool { self.parentIDs.isEmpty }
|
|
@inlinable public var isDeep: Bool { self.children.isEmpty }
|
|
|
|
internal init(id: Int, children: [ChildRef]) {
|
|
self.packageID = id
|
|
self.children = children
|
|
}
|
|
}
|
|
|
|
extension ApkPackageGraphNode: Equatable, Hashable {
|
|
public static func == (lhs: ApkPackageGraphNode, rhs: ApkPackageGraphNode) -> Bool {
|
|
lhs.packageID == rhs.packageID
|
|
}
|
|
|
|
public func hash(into hasher: inout Hasher) {
|
|
self.packageID.hash(into: &hasher)
|
|
}
|
|
}
|
|
|
|
extension ApkPackageGraphNode {
|
|
public struct ChildRef {
|
|
let constraint: Constraint
|
|
let packageID: Int
|
|
let versionSpec: ApkVersionSpecification
|
|
}
|
|
|
|
public enum Constraint {
|
|
case dependency, installIf
|
|
}
|
|
}
|
|
|
|
extension ApkIndex {
|
|
public func at(node: ApkPackageGraphNode) -> ApkIndexPackage {
|
|
self.packages[node.packageID]
|
|
}
|
|
}
|