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

Class BaseTree

source code

object --+
         |
        BaseTree
Known Subclasses:

Base class for representing trees. Don't instantiate this: use ImmutableTree or MutableTree.

Instance Methods [hide private]
 
__init__(self, root)
x.__init__(...) initializes x; see help(type(x)) for signature
source code
 
__getitem__(self, index) source code
 
__len__(self)
Number of nodes in total.
source code
 
postorder(self)
Returns a postorder list of all the nodes in this node's subtree, including itself.
source code
 
postorder_index(self, node)
Returns the index of this node in the tree according to a postorder ordering.
source code
 
find_parent(self, node)
Searches for the by of the given node (by identity).
source code
 
replace_node(self, postorder_index, new_node)
Removes the node and the given postorder index and replaces it with another node.
source code
 
__str__(self)
str(x)
source code
 
__repr__(self)
repr(x)
source code
 
__eq__(self, other) source code
 
unordered_equal(self, other) source code
 
copy(self)
Deep copy
source code
 
can_embed_subtree(self, node) source code

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

Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, root)
(Constructor)

source code 

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

Overrides: object.__init__
(inherited documentation)

postorder_index(self, node)

source code 

Returns the index of this node in the tree according to a postorder ordering. This is inefficient, because it has to recompute the postorder every time. It is more efficient on ImmutableTree, because it can precompute the postorder.

Note that it is looking for a node by identity, not equality.

Raises:
  • ValueError - if the node is not found in the graph.

find_parent(self, node)

source code 

Searches for the by of the given node (by identity). Returns the parent, or None if the node is not found.

__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)