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

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

#include <polygon.H>

Collaboration diagram for 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 next vertex (no exception on overflow).
 
void next ()
 Advance to 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";
Rectangular point in the plane.
Definition point.H:156
Iterator over the vertices of a regular polygon.
Definition polygon.H:944
bool has_curr() const
Check if there is a current vertex.
Definition polygon.H:960
A regular polygon defined by center, side length, and vertex count.
Definition polygon.H:829

Definition at line 943 of file polygon.H.

Constructor & Destructor Documentation

◆ Vertex_Iterator()

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 952 of file polygon.H.

Member Function Documentation

◆ get_current_vertex()

Vertex & 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 965 of file polygon.H.

References ah_overflow_error_if, curr, Regular_Polygon::get_vertex(), has_curr(), Aleph::maps(), poly, and vertex.

Referenced by TEST_F(), and TEST_F().

◆ has_curr()

bool 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 960 of file polygon.H.

References curr, poly, and Regular_Polygon::size().

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

◆ next()

void Regular_Polygon::Vertex_Iterator::next ( )
inline

Advance to next vertex.

Exceptions
std::overflow_errorIf already at end.

Definition at line 980 of file polygon.H.

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

Referenced by TEST_F().

◆ next_ne()

void Regular_Polygon::Vertex_Iterator::next_ne ( )
inlinenoexcept

Advance to next vertex (no exception on overflow).

Definition at line 976 of file polygon.H.

References curr.

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

◆ prev()

void Regular_Polygon::Vertex_Iterator::prev ( )
inline

Move to previous vertex.

Exceptions
std::underflow_errorIf already at beginning.

Definition at line 989 of file polygon.H.

References ah_underflow_error_if, curr, has_curr(), and Aleph::maps().

Member Data Documentation

◆ curr

size_t Regular_Polygon::Vertex_Iterator::curr
private

Current vertex index.

Definition at line 946 of file polygon.H.

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

◆ poly

const Regular_Polygon& Regular_Polygon::Vertex_Iterator::poly
private

Reference to the polygon.

Definition at line 945 of file polygon.H.

Referenced by get_current_vertex(), and has_curr().

◆ vertex

Vertex Regular_Polygon::Vertex_Iterator::vertex
private

Cache for compatibility with Polygon::Vertex_Iterator.

Definition at line 947 of file polygon.H.

Referenced by get_current_vertex().


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