Merge branch 'feature/model_tree_traversal' of https://gitlab.verizon.com/BPHV_MIPS/mvm_core_ui into feature/required_behaviors
This commit is contained in:
commit
a043cb5eb5
@ -57,9 +57,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)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -338,11 +338,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