Elements.pyECSS.Entity.EntityDfsIterator

class Elements.pyECSS.Entity.EntityDfsIterator(entity: Elements.pyECSS.Entity.Entity)[source]

This is a depth-first-iterator for Hierarchical Entities (Iterables) and their Components, based on the Iterator design pattern

Parameters

Iterator ([type]) – [description]

Here is the explanation for the code above:
  1. This is a depth-first-iterator for Hierarchical Entities (Iterables) and their Components,

based on the Iterator design pattern
  1. We have a stack to keep track of the iterators that we have to go through.

  2. We push the Entity’s iterator on the stack, that is the iterator that iterates through the Entity’s children.

  3. We get the iterator from the top of the stack, and try to get the next child.

  4. If we get a StopIteration exception, then we have reached the end of the iterator, and we pop it off the stack.

  5. If we get a node, then we check if it is an Entity, and if it is, we push the Entity’s iterator on the stack, and return the node.

  6. If we get a node and it is not an Entity, then we return the node.

__init__(entity: Elements.pyECSS.Entity.Entity)None[source]

Initialize self. See help(type(self)) for accurate signature.

Methods

__init__(entity)

Initialize self.