Skip to content

Commit

Permalink
make LazyModule.nodes accessable by users.
Browse files Browse the repository at this point in the history
1. make LazyModule.nodes accessable to user for debugging and reuse
   Nodes.
2. refactor childrenIterator to nodeIterator, add nodeIterator to access
   all children's BaseNode.
  • Loading branch information
sequencer committed Feb 21, 2020
1 parent 28a0243 commit 8c5c53c
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/main/scala/diplomacy/LazyModule.scala
Original file line number Diff line number Diff line change
Expand Up @@ -112,12 +112,19 @@ abstract class LazyModule()(implicit val p: Parameters)
children.filter(!_.omitGraphML).foreach { c => c.edgesGraphML(buf, pad) }
}

def nodeIterator(iterfunc: (LazyModule) => Unit): Unit = {
def childrenIterator(iterfunc: (LazyModule) => Unit): Unit = {
iterfunc(this)
children.foreach( _.nodeIterator(iterfunc) )
children.foreach( _.childrenIterator(iterfunc) )
}

def nodeIterator(iterfunc: (BaseNode) => Unit): Unit = {
nodes.foreach(iterfunc)
childrenIterator(_.nodes.foreach(iterfunc))
}

def getChildren = children

def getNodes = nodes
}

object LazyModule
Expand Down

0 comments on commit 8c5c53c

Please sign in to comment.