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

Iterator over the vertices of a regular polygon. More...

#include <polygon.H>

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

Public Member Functions

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

Private Attributes

const Regular_Polygonpoly_
 Reference to the polygon.
 
size_t curr_
 Current vertex index.
 
Vertex vertex_
 Cache for compatibility with Polygon::Vertex_Iterator.
 

Detailed Description

Iterator over the vertices of a regular polygon.

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

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

Definition at line 1244 of file polygon.H.

Constructor & Destructor Documentation

◆ Vertex_Iterator()

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

Construct iterator from a regular polygon.

Parameters
polyThe polygon to iterate over.

Definition at line 1253 of file polygon.H.

Member Function Documentation

◆ get_current_vertex()

Vertex & Aleph::Regular_Polygon::Vertex_Iterator::get_current_vertex ( )
inline

Get the current vertex.

Returns
Reference to the current vertex.
Exceptions
std::overflow_errorIf no current vertex exists.

Definition at line 1266 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 vertex_.

Referenced by TEST_F(), and TEST_F().

◆ has_curr()

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

Check if there is a current vertex.

Returns
True if a current vertex exists.

Definition at line 1261 of file polygon.H.

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

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

◆ next()

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

Advance to the next vertex.

Exceptions
std::overflow_errorIf already at end.

Definition at line 1280 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::Vertex_Iterator::next_ne ( )
inlinenoexcept

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

Definition at line 1276 of file polygon.H.

References curr_.

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

◆ prev()

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

Move to previous vertex.

Exceptions
std::underflow_errorIf already at the beginning.

Definition at line 1288 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::Vertex_Iterator::curr_
private

Current vertex index.

Definition at line 1247 of file polygon.H.

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

◆ poly_

const Regular_Polygon& Aleph::Regular_Polygon::Vertex_Iterator::poly_
private

Reference to the polygon.

Definition at line 1246 of file polygon.H.

Referenced by get_current_vertex(), and has_curr().

◆ vertex_

Vertex Aleph::Regular_Polygon::Vertex_Iterator::vertex_
private

Cache for compatibility with Polygon::Vertex_Iterator.

Definition at line 1248 of file polygon.H.

Referenced by get_current_vertex().


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