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


A lightweight object that gives access to all immediate children of a given packet. More...

#include <packet/packet.h>

Public Member Functions

 PacketChildren (const PacketChildren &)=default
 
Default copy constructor. More...
 
 PacketChildren (const Packet *parent)
 
Creates a new object for iterating through the immediate children of the given packet. More...
 
PacketChildrenoperator= (const PacketChildren &)=default
 
Default copy assignment operator. More...
 
ChildIterator begin () const
 
Returns an iterator at the beginning of the range of children. More...
 
ChildIterator end () const
 
Returns an iterator at the end of the range of children. More...
 

Detailed Description


A lightweight object that gives access to all immediate children of a given packet.

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

Packet* parent = ...;
for (Packet* child : parent->children()) { ... }

In Python, PacketChildren is an iterable object:

parent = ...
for child in parent.children():
...
Python
Instead of the C++ interface described here, in Python the classes PacketChildren and ChildIterator together implement the Python iterable/iterator interface. The class PacketChildren has just the single function __iter__(), which returns a ChildIterator; then ChildIterator implements next(), which either returns the next child 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).