Package groupthink :: Module aatree :: Class SumWalker
[hide private]
[frames] | no frames]

Class SumWalker

source code

Walker --+
         |
        SumWalker

SumWalker is designed to walk over full trees where each leaf has annotation 1 and the monoid is +. Target is the zero-indexed position of the target node.

There is one exception: the last node in every tree has annotation 0.

Instance Methods [hide private]
 
prepare_descend(self, target)
An optional method to prepare for descent
source code
int
descend(self, node)
Returns: descend must return 0 if the node in question is the one desired, -1 if the left child would be better, or 1 if the right child would be better.
source code
 
prepare_ascend(self)
An optional method to prepare for ascent
source code
bool
ascend(self, node)
Returns: ascend should return True iff it should run again on the parent of node.
source code
Class Variables [hide private]
  target = None
  offset = None
Method Details [hide private]

prepare_descend(self, target)

source code 

An optional method to prepare for descent

Overrides: Walker.prepare_descend
(inherited documentation)

descend(self, node)

source code 
Parameters:
  • node - A node from which to descend.
Returns: int
descend must return 0 if the node in question is the one desired, -1 if the left child would be better, or 1 if the right child would be better.
Overrides: Walker.descend
(inherited documentation)

prepare_ascend(self)

source code 

An optional method to prepare for ascent

Overrides: Walker.prepare_ascend
(inherited documentation)

ascend(self, node)

source code 
Parameters:
  • node - A node from which to ascend
Returns: bool
ascend should return True iff it should run again on the parent of node. It should set the walker's internal state such that a subsequent descent would retrace these steps.
Overrides: Walker.ascend
(inherited documentation)