Algorithms_in_C++ 1.0.0
Set of algorithms implemented in C++.
Loading...
Searching...
No Matches
greedy_algorithms::DigitSeparation Class Reference

A class that provides methods to separate the digits of a large positive number. More...

Public Member Functions

 DigitSeparation ()
 Default constructor for the DigitSeparation class.
 
std::vector< std::int64_tdigitSeparationReverseOrder (std::int64_t largeNumber) const
 Implementation of digitSeparationReverseOrder method.
 
std::vector< std::int64_tdigitSeparationForwardOrder (std::int64_t largeNumber) const
 Implementation of digitSeparationForwardOrder method.
 

Detailed Description

A class that provides methods to separate the digits of a large positive number.

Constructor & Destructor Documentation

◆ DigitSeparation()

greedy_algorithms::DigitSeparation::DigitSeparation ( )
inline

Default constructor for the DigitSeparation class.

40{}

Member Function Documentation

◆ digitSeparationForwardOrder()

std::vector< std::int64_t > greedy_algorithms::DigitSeparation::digitSeparationForwardOrder ( std::int64_t largeNumber) const
inline

Implementation of digitSeparationForwardOrder method.

Parameters
largeNumberThe large number to separate digits from.
Returns
A vector of digits in forward order.
69 {
71 digitSeparationReverseOrder(largeNumber);
72 std::reverse(result.begin(), result.end());
73 return result;
74 }
std::vector< std::int64_t > digitSeparationReverseOrder(std::int64_t largeNumber) const
Implementation of digitSeparationReverseOrder method.
Definition digit_separation.cpp:48
uint64_t result(uint64_t n)
Definition fibonacci_sum.cpp:76
T reverse(T... args)
Here is the call graph for this function:

◆ digitSeparationReverseOrder()

std::vector< std::int64_t > greedy_algorithms::DigitSeparation::digitSeparationReverseOrder ( std::int64_t largeNumber) const
inline

Implementation of digitSeparationReverseOrder method.

Parameters
largeNumberThe large number to separate digits from.
Returns
A vector of digits in reverse order.
49 {
51 if (largeNumber != 0) {
52 while (largeNumber != 0) {
53 result.push_back(std::abs(largeNumber % 10));
54 largeNumber /= 10;
55 }
56 } else {
57 result.push_back(0);
58 }
59 return result;
60 }

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