Package jazzparser :: Package misc :: Package tree :: Module datastructs :: Class Node
[hide private]
[frames] | no frames]

Class Node

source code

object --+
         |
        Node

Node of a tree.

Instance Methods [hide private]
 
__init__(self, label, *args)
x.__init__(...) initializes x; see help(type(x)) for signature
source code
 
is_leaf(self) source code
 
__len__(self)
Returns number of children
source code
 
all_nodes(self) source code
 
__str__(self)
str(x)
source code
 
__repr__(self)
repr(x)
source code
 
__getitem__(self, index) source code
 
find_parent(self, node)
Searches for the by of the given node (by identity).
source code
 
postorder(self)
Returns a postorder list of all the nodes in this node's subtree, including itself.
source code
 
__eq__(self, other) source code
 
unordered_equal(self, other)
Our tree representation preserves the order of children of a node.
source code
 
copy(self) source code
 
leftmost_leaf(self)
Returns the leftmost leaf of this subtree.
source code
 
rightmost_leaf(self)
Returns the rightmost leaf of this subtree.
source code

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __setattr__, __sizeof__, __subclasshook__

Static Methods [hide private]
 
unode(*args)
Creates an unlabeled node.
source code
Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, label, *args)
(Constructor)

source code 

x.__init__(...) initializes x; see help(type(x)) for signature

Overrides: object.__init__
(inherited documentation)

unode(*args)
Static Method

source code 

Creates an unlabeled node. Label will be set to None.

__str__(self)
(Informal representation operator)

source code 

str(x)

Overrides: object.__str__
(inherited documentation)

__repr__(self)
(Representation operator)

source code 

repr(x)

Overrides: object.__repr__
(inherited documentation)

find_parent(self, node)

source code 

Searches for the by of the given node (by identity). Returns all of the parents of that node we can find.

unordered_equal(self, other)

source code 

Our tree representation preserves the order of children of a node. Two trees are only equal according to __eq__ if their child ordering is the same at every node. This method checks if the two can be considered equal if the same ordering is not required.