Regina Calculation Engine
Public Member Functions | List of all members
regina::PacketDescendants Class Reference


A lightweight object that gives access to all strict descendants of a given packet. More...

#include <packet/packet.h>

Public Member Functions

 PacketDescendants (const PacketDescendants &)=default
 
Default copy constructor. More...
 
 PacketDescendants (const Packet *subtree)
 
Creates a new object for iterating through the strict descendants of the given packet. More...
 
PacketDescendantsoperator= (const PacketDescendants &)=default
 
Default copy assignment operator. More...
 
SubtreeIterator begin () const
 
Returns an iterator at the beginning of the range of strict descendants. More...
 
SubtreeIterator end () const
 
Returns an iterator at the end of the range of strict descendants. More...
 

Detailed Description


A lightweight object that gives access to all strict descendants of a given packet.

The purpose of this class is to support iteration through all strict descendants of a packet p using C++11 range-based for loops:

Packet* parent = ...;
for (Packet* desc : parent->descendants()) { ... }

In Python, PacketDescendants is an iterable object:

parent = ...
for desc in parent.descendants():
...
Python
Instead of the C++ interface described here, in Python the classes PacketDescendants and SubtreeIterator together implement the Python iterable/iterator interface. The class PacketDescendants has just the single function __iter__(), which returns a SubtreeIterator; then SubtreeIterator implements next(), which either returns the next descendant packet in the iteration or else throws a StopException if there are no more children to return.

The documentation for this class was generated from the following file:

Copyright © 1999-2021, The Regina development team
This software is released under the GNU General Public License, with some additional permissions; see the source code for details.
For further information, or to submit a bug or other problem, please contact Ben Burton (bab@maths.uq.edu.au).