Regina 7.0 Calculation Engine
|
A lightweight object that gives access to all strict descendants of a given packet. More...
#include <packet/packet.h>
Public Types | |
using | packet_type = typename std::conditional< const_, const Packet, Packet >::type |
Either Packet or const Packet , according to the template argument const_. More... | |
Public Member Functions | |
PacketDescendants (const PacketDescendants &)=default | |
Default copy constructor. More... | |
PacketDescendants (std::shared_ptr< packet_type > subtree) | |
Creates a new object for iterating through the strict descendants of the given packet. More... | |
PacketDescendants & | operator= (const PacketDescendants &)=default |
Default copy assignment operator. More... | |
SubtreeIterator< const_ > | begin () const |
Returns an iterator at the beginning of the range of strict descendants. More... | |
SubtreeIterator< const_ > | end () const |
Returns an iterator at the end of the range of strict descendants. More... | |
bool | operator== (const PacketDescendants &rhs) const |
Determines whether this and the given object are designed to iterate over strict descendants of the same packet. More... | |
bool | operator!= (const PacketDescendants &rhs) const |
Determines whether this and the given object are designed to iterate over strict descendants of different packets. More... | |
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:
In Python, PacketDescendants is an iterable object:
Each object of this class will hold a std::shared_ptr to the packet whose descendants it gives access to. This guarantees that the packet will not be destroyed during iteration, but it also means that you must ensure that you dispose of these objects once you are finished with them.
These are lightweight objects, small enough to pass by value and swap with std::swap(), with no need for any specialised move operations or swap functions. Copies of a PacketDescendants will iterate over the descendants of the same underlying packet.
const_ | Indicates whether this iterator should offer const or non-const access to the packet tree. |
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. All iteration in Python is non-const (i.e., Python exclusively uses the classes where const_ is false
). using regina::PacketDescendants< const_ >::packet_type = typename std::conditional<const_, const Packet, Packet>::type |
|
default |
Default copy constructor.
|
inline |
Creates a new object for iterating through the strict descendants of the given packet.
subtree | the packet whose strict descendants we will iterate through. |
|
inline |
Returns an iterator at the beginning of the range of strict descendants.
This will point to the first child packet (if one exists) of the packet whose descendants we are iterating over.
iter()
, as described in the class notes.
|
inline |
Returns an iterator at the end of the range of strict descendants.
iter()
, as described in the class notes.bool regina::PacketDescendants< const_ >::operator!= | ( | const PacketDescendants< const_ > & | rhs | ) | const |
Determines whether this and the given object are designed to iterate over strict descendants of different packets.
true
if and only if this object and rhs iterate over descendants of different packets.
|
default |
Default copy assignment operator.
bool regina::PacketDescendants< const_ >::operator== | ( | const PacketDescendants< const_ > & | rhs | ) | const |
Determines whether this and the given object are designed to iterate over strict descendants of the same packet.
true
if and only if this object and rhs iterate over descendants of the same packet.