DuxReiNummariae 1.0.0-alpha.23
Simple and powerful budgeting application
 
Loading...
Searching...
No Matches
drn::budgeting::Budget::Iterator Class Reference

Provides functionality to traverse through a collection of elements sequentially, allowing controlled access to each element in the collection. More...

#include <Budget.h>

Collaboration diagram for drn::budgeting::Budget::Iterator:

Public Types

using const_pointer = const value_type*
 The type used when the value is to be a pointer to the value.
 
using const_reference = const value_type&
 The type used when the value is to be a const-ref to the value.
 
using difference_type = std::ptrdiff_t
 Type used to represent the distance between two iterators.
 
using iterator_category = std::forward_iterator_tag
 Standard iterator category tag.
 
using value_type
 

Public Member Functions

 Iterator (const Budget &budget)
 Fully initialises the object to point to the budget. Upon successful construction will be pointing just past the end of the budget.
 
Iterator begin () const noexcept
 Returns an iterator pointing to the first item in the collection within the budget.
 
Iterator end () const noexcept
 Returns an iterator pointing to the position after the last element in the budget's managed collection.
 
const_reference operator* () const noexcept
 Star-operator to the current budget item.
 
Iteratoroperator++ ()
 Prefix increment operator.
 
Iterator operator++ (int)
 Postfix increment operator.
 
const_pointer operator-> () const noexcept
 Arrow-operator to the current budget item.
 
bool operator== (const Iterator &other) const noexcept
 Equality operator with the same semantics: both being at the end or both observe the same budgt item is considered to be equivalent.
 

Detailed Description

Provides functionality to traverse through a collection of elements sequentially, allowing controlled access to each element in the collection.

The iterator ensures encapsulation by abstracting the traversal mechanism, making it independent of the collection's internal structure. It can be utilised to iterate through various types of collections, such as lists, arrays, or other custom data structures.

The class provides essential operations for iteration, such as advancing to the next element, checking for the end of the collection, and accessing the current element.

Member Typedef Documentation

◆ const_pointer

The type used when the value is to be a pointer to the value.

◆ const_reference

The type used when the value is to be a const-ref to the value.

◆ difference_type

Type used to represent the distance between two iterators.

◆ iterator_category

using drn::budgeting::Budget::Iterator::iterator_category = std::forward_iterator_tag

Standard iterator category tag.

◆ value_type

Initial value:
std::pair<
>
A smart pointer for observing another pointer. This means that it preforms no memory management on th...
Definition ObserverPtr.hpp:42
Identifies a budget item by its type and source. The structure is used to uniquely represent a budget...
Definition BudgetItemIdentifier.h:43

The type of value that the iterator points to, representing a the budget item ID and its monetary budget item.

Constructor & Destructor Documentation

◆ Iterator()

drn::budgeting::Budget::Iterator::Iterator ( const Budget & budget)
explicit

Fully initialises the object to point to the budget. Upon successful construction will be pointing just past the end of the budget.

Parameters
budgetThe budget to iterate over.
Here is the call graph for this function:
Here is the caller graph for this function:

Member Function Documentation

◆ begin()

Iterator drn::budgeting::Budget::Iterator::begin ( ) const
nodiscardnoexcept

Returns an iterator pointing to the first item in the collection within the budget.

This method initializes an iterator to start iterating through the available budget items, starting with the first category containing items. If no items are present in any category, the iterator will be initialized to its final state, indicating the end of the collection.

Returns
An iterator initialized to the first budget item or indicating the end of the collection if no items are available.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ end()

Iterator drn::budgeting::Budget::Iterator::end ( ) const
nodiscardnoexcept

Returns an iterator pointing to the position after the last element in the budget's managed collection.

This method allows iteration over the budget's items to stop gracefully. By calling this method, the iterator returned can be used to check termination of a loop or other forms of traversal.

Returns
An iterator positioned at the end of the budget's collection, signifying traversal completion.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ operator*()

const_reference drn::budgeting::Budget::Iterator::operator* ( ) const
nodiscardnoexcept

Star-operator to the current budget item.

Returns
The current budget item.

◆ operator++() [1/2]

Iterator & drn::budgeting::Budget::Iterator::operator++ ( )

Prefix increment operator.

Returns
The object after the increment operation.
Here is the call graph for this function:

◆ operator++() [2/2]

Iterator drn::budgeting::Budget::Iterator::operator++ ( int )

Postfix increment operator.

Returns
The object before the increment operation.
Here is the call graph for this function:

◆ operator->()

const_pointer drn::budgeting::Budget::Iterator::operator-> ( ) const
nodiscardnoexcept

Arrow-operator to the current budget item.

Returns
The current budget item.

◆ operator==()

bool drn::budgeting::Budget::Iterator::operator== ( const Iterator & other) const
nodiscardnoexcept

Equality operator with the same semantics: both being at the end or both observe the same budgt item is considered to be equivalent.

Precondition
The other iterator must come from the same budget object.
Parameters
otherThe other object to compare against.
Returns
True when the two iterators point to the same object, false otherwise.
Here is the call graph for this function: