| Home | Trees | Index | Help |
|---|
object --+
|
Node
NamedNodeA node in a n-ary tree.
Instances of this class represent nodes that make up a tree structure.
Each node can have one parent (a node with a parent of None
is a root node) and an arbitary number of children.
The parent of a node is defined on creation of the node, but can be changed later. Nodes keep track of their children automatically, so changing the parent of a node from A to B will automatically remove the node from A's list of children and add it to B's list of children.
Children of a node are sorted in the order in which they were attached to the parent.| Method Summary | |
|---|---|
Initialize a new node. | |
Hook for subclasses to register a parent change. | |
Apply a function to all nodes of the (sub)tree rooted at this node. | |
| Inherited from object | |
x.__delattr__('name') <==> del x.name | |
x.__getattribute__('name') <==> x.name | |
Return hash(x)... | |
Return a new object with type S, a subtype of T... | |
helper for pickle | |
helper for pickle | |
Return repr(x)... | |
x.__setattr__('name', value) <==> x.name = value | |
Return str(x)... | |
| Property Summary | |
|---|---|
| [Node] | children: List of child nodes. |
| Node or None | parent: Parent node, or None if this is the root of the tree. |
| Node | root: Root node of the tree this node is a member of. |
| Method Details |
|---|
__init__(self,
parent)
Initialize a new node.
|
_set_parent_(self, parent)Hook for subclasses to register a parent change. Subclasses can implement this method to execute stuff that has to be done whenever a node gets a new parent. |
walk(self, function, *args, **kwargs)Apply a function to all nodes of the (sub)tree rooted at this node. The function is first applied to this node, then to the first child node, then to all children of the first child node recursively, then to the next child node, etc. The function is called with the repective node as the first argument, followed by the positional arguments and keyword arguments provided in the call towalk.
|
| Property Details |
|---|
childrenList of child nodes. (readonly) |
parentParent node, orNone if this is the root of the tree.
|
rootRoot node of the tree this node is a member of. (readonly) |
| Home | Trees | Index | Help |
|---|
| Generated by Epydoc 2.1 on Wed Jan 7 23:02:11 2009 | http://epydoc.sf.net |