signature fix. template traversal conformance.
This commit is contained in:
parent
4a491cbfaa
commit
cb2c42793a
@ -43,9 +43,9 @@ public extension Array where Element == MoleculeModelProtocol {
|
||||
}
|
||||
}
|
||||
|
||||
func depthFirstTraverse(options: TreeTraversalOptions, depth: Int, callback: (Int, MoleculeModelProtocol)->Void) {
|
||||
func depthFirstTraverse(options: TreeTraversalOptions, depth: Int, onVisit: (Int, MoleculeModelProtocol)->Void) {
|
||||
forEach { (molecule) in
|
||||
molecule.depthFirstTraverse(options: options, depth: depth, onVisit: callback)
|
||||
molecule.depthFirstTraverse(options: options, depth: depth, onVisit: onVisit)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -9,7 +9,7 @@
|
||||
import Foundation
|
||||
|
||||
|
||||
public protocol TemplateModelProtocol: PageModelProtocol, ModelProtocol {
|
||||
public protocol TemplateModelProtocol: PageModelProtocol, ModelProtocol, MoleculeTreeTraversalProtocol {
|
||||
var template: String { get }
|
||||
var rootMolecules: [MoleculeModelProtocol] { get }
|
||||
}
|
||||
@ -27,4 +27,12 @@ public extension TemplateModelProtocol {
|
||||
static var categoryName: String {
|
||||
return "\(TemplateModelProtocol.self)"
|
||||
}
|
||||
|
||||
func reduceDepthFirstTraverse<Result>(options: TreeTraversalOptions, depth: Int, initialResult: Result, nextPartialResult: (Result, MoleculeModelProtocol, Int) -> Result) -> Result {
|
||||
return rootMolecules.reduceDepthFirstTraverse(options: options, depth: depth, initialResult: initialResult, nextPartialResult: nextPartialResult)
|
||||
}
|
||||
|
||||
func depthFirstTraverse(options: TreeTraversalOptions, depth: Int, onVisit: (Int, MoleculeModelProtocol) -> Void) {
|
||||
return rootMolecules.depthFirstTraverse(options: options, depth: depth, onVisit: onVisit)
|
||||
}
|
||||
}
|
||||
|
||||
@ -335,12 +335,12 @@ import UIKit
|
||||
initialLoadFinished = true
|
||||
initialLoad()
|
||||
}
|
||||
|
||||
print("total molecules in tree: \(model?.rootMolecules.countMolecules() ?? 0)")
|
||||
|
||||
print("total molecules in tree: \(model?.countMolecules() ?? 0)")
|
||||
|
||||
model?.rootMolecules.printMolecules()
|
||||
|
||||
let allVideoMolecules:[BGVideoImageMoleculeModel] = model?.rootMolecules.allMoleculesOfType() ?? []
|
||||
let allVideoMolecules:[BGVideoImageMoleculeModel] = model?.allMoleculesOfType() ?? []
|
||||
print("video molecules: \(allVideoMolecules.count)")
|
||||
|
||||
handleNewDataAndUpdateUI()
|
||||
|
||||
Loading…
Reference in New Issue
Block a user