Aleph-w 3.0
A C++ Library for Data Structures and Algorithms
Loading...
Searching...
No Matches
Aleph::Regular_Polygon::Segment_Iterator Class Reference

Iterator over the edges (segments) of a regular polygon. More...

#include <polygon.H>

Collaboration diagram for Aleph::Regular_Polygon::Segment_Iterator:
[legend]

Public Member Functions

 Segment_Iterator (const Regular_Polygon &poly)
 Construct segment iterator from a regular polygon.
 
bool has_curr () const
 Check if there is a current segment.
 
Segment get_current_segment () const
 Get the current segment (edge).
 
void next_ne () noexcept
 Advance to the next segment (no exception on overflow).
 
void next ()
 Advance to the next segment.
 
void prev ()
 Move to the previous segment.
 

Private Attributes

const Regular_Polygonpoly_
 Reference to the polygon.
 
size_t curr_
 Current segment index.
 

Detailed Description

Iterator over the edges (segments) of a regular polygon.

This iterator provides the same interface as Polygon::Segment_Iterator to enable generic code that works with both polygon types.

Regular_Polygon hex(Point(0, 0), 50, 6);
for (Regular_Polygon::Segment_Iterator it(hex); it.has_curr(); it.next())
std::cout << it.get_current_segment().to_string() << "\n";
Represents a point with rectangular coordinates in a 2D plane.
Definition point.H:229
Iterator over the edges (segments) of a regular polygon.
Definition polygon.H:1308
bool has_curr() const
Check if there is a current segment.
Definition polygon.H:1323
A regular polygon defined by center, side length, and vertex count.
Definition polygon.H:1132

Definition at line 1307 of file polygon.H.

Constructor & Destructor Documentation

◆ Segment_Iterator()

Aleph::Regular_Polygon::Segment_Iterator::Segment_Iterator ( const Regular_Polygon poly)
inline

Construct segment iterator from a regular polygon.

Parameters
polyThe polygon to iterate over.

Definition at line 1315 of file polygon.H.

Member Function Documentation

◆ get_current_segment()

Segment Aleph::Regular_Polygon::Segment_Iterator::get_current_segment ( ) const
inline

Get the current segment (edge).

Returns
The segment from the current vertex to the next.
Exceptions
std::overflow_errorIf no current segment exists.

Definition at line 1328 of file polygon.H.

References ah_overflow_error_if, curr_, Aleph::divide_and_conquer_partition_dp(), Aleph::Regular_Polygon::get_vertex(), has_curr(), poly_, and Aleph::Regular_Polygon::size().

Referenced by TEST_F(), and TEST_F().

◆ has_curr()

bool Aleph::Regular_Polygon::Segment_Iterator::has_curr ( ) const
inline

Check if there is a current segment.

Returns
True if a current segment exists.

Definition at line 1323 of file polygon.H.

References curr_, poly_, and Aleph::Regular_Polygon::size().

Referenced by get_current_segment(), next(), prev(), TEST_F(), and TEST_F().

◆ next()

void Aleph::Regular_Polygon::Segment_Iterator::next ( )
inline

Advance to the next segment.

Exceptions
std::overflow_errorIf already at end.

Definition at line 1340 of file polygon.H.

References ah_overflow_error_if, Aleph::divide_and_conquer_partition_dp(), has_curr(), and next_ne().

Referenced by TEST_F().

◆ next_ne()

void Aleph::Regular_Polygon::Segment_Iterator::next_ne ( )
inlinenoexcept

Advance to the next segment (no exception on overflow).

Definition at line 1336 of file polygon.H.

References curr_.

Referenced by next(), TEST_F(), and TEST_F().

◆ prev()

void Aleph::Regular_Polygon::Segment_Iterator::prev ( )
inline

Move to the previous segment.

Exceptions
std::underflow_errorIf already at the beginning.

Definition at line 1348 of file polygon.H.

References ah_underflow_error_if, curr_, Aleph::divide_and_conquer_partition_dp(), and has_curr().

Member Data Documentation

◆ curr_

size_t Aleph::Regular_Polygon::Segment_Iterator::curr_
private

Current segment index.

Definition at line 1310 of file polygon.H.

Referenced by get_current_segment(), has_curr(), next_ne(), and prev().

◆ poly_

const Regular_Polygon& Aleph::Regular_Polygon::Segment_Iterator::poly_
private

Reference to the polygon.

Definition at line 1309 of file polygon.H.

Referenced by get_current_segment(), and has_curr().


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