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
|
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
|
import Foundation
|
||||||
|
|
||||||
|
|
||||||
public protocol TemplateModelProtocol: PageModelProtocol, ModelProtocol {
|
public protocol TemplateModelProtocol: PageModelProtocol, ModelProtocol, MoleculeTreeTraversalProtocol {
|
||||||
var template: String { get }
|
var template: String { get }
|
||||||
var rootMolecules: [MoleculeModelProtocol] { get }
|
var rootMolecules: [MoleculeModelProtocol] { get }
|
||||||
}
|
}
|
||||||
@ -27,4 +27,12 @@ public extension TemplateModelProtocol {
|
|||||||
static var categoryName: String {
|
static var categoryName: String {
|
||||||
return "\(TemplateModelProtocol.self)"
|
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)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -336,11 +336,11 @@ import UIKit
|
|||||||
initialLoad()
|
initialLoad()
|
||||||
}
|
}
|
||||||
|
|
||||||
print("total molecules in tree: \(model?.rootMolecules.countMolecules() ?? 0)")
|
print("total molecules in tree: \(model?.countMolecules() ?? 0)")
|
||||||
|
|
||||||
model?.rootMolecules.printMolecules()
|
model?.rootMolecules.printMolecules()
|
||||||
|
|
||||||
let allVideoMolecules:[BGVideoImageMoleculeModel] = model?.rootMolecules.allMoleculesOfType() ?? []
|
let allVideoMolecules:[BGVideoImageMoleculeModel] = model?.allMoleculesOfType() ?? []
|
||||||
print("video molecules: \(allVideoMolecules.count)")
|
print("video molecules: \(allVideoMolecules.count)")
|
||||||
|
|
||||||
handleNewDataAndUpdateUI()
|
handleNewDataAndUpdateUI()
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user