HRCore V1.1.0
A High Resolution Calculation Library
Loading...
Searching...
No Matches
HRCore::Value::Integer Class Reference

Integer type. More...

#include <Value.hpp>

Inheritance diagram for HRCore::Value::Integer:
Inheritance graph
Collaboration diagram for HRCore::Value::Integer:
Collaboration graph

Classes

class  DivisionResult_t
 Type defination of division result (For Integer only). More...
 

Public Member Functions

 Integer (Storage::Interface *ptr, bool positive=true, bool autoRelease=false, bool sim=true)
 Construct a new Integer object. More...
 
Integer make ()
 Make a new object with same Interface type. More...
 
 Integer (Integer &&c)
 Move a Integer object. More...
 
Integeroperator= (Integer &&c)
 Move operator. More...
 
 Integer (const Integer &c)
 Copy and construct a new Integer object. More...
 
Integeroperator= (ival_t num)
 Reload of operator= to support a ival_t be converted to Integer. More...
 
Integeroperator= (const Integer &c)
 Copy operator. More...
 
Integer operator+ (const Integer &r)
 Reload of operator+. More...
 
Integer operator- (const Integer &r)
 Reload of operator-(r) More...
 
Integer operator* (const Integer &r)
 Reload of operator*(r) More...
 
DivisionResult_t divideBy (const Integer &r)
 A function to calculate (*this / r) More...
 
Integer operator/ (const Integer &r)
 Reload of operator/. More...
 
Integer operator% (const Integer &r)
 Reload of operator%. More...
 
Integer operator- () const
 Reload of operator-() const. More...
 
Integer operator+ () const
 Reload of operator+() const. More...
 
bool positive () const
 Return the sign of object. More...
 
void positive (bool p)
 Set the sign of object. More...
 
bool operator< (const Integer &r)
 Compare this and r with operator <. More...
 
bool operator> (const Integer &r)
 Compare this and r with operator > More...
 
bool operator== (const Integer &r)
 Test if (r == this) More...
 
bool operator>= (const Integer &r)
 Test if (this >= r) More...
 
bool operator<= (const Integer &r)
 Test if (this <= r) More...
 
Integer operator<< (size_t n)
 Reload of << (Left shift) More...
 
Integer operator>> (size_t n)
 Reload of >> (Logical right shift) More...
 

Static Public Member Functions

template<typename T >
static Integer make ()
 Construct a new Integer object using given type of Storage::Interface implement. More...
 

Static Protected Member Functions

static int8_t _absRelation (const Integer &l, const Integer &r)
 Get relation of l and r. More...
 
static bool _absGreater (const Integer &l, const Integer &r)
 Examine if l > r. More...
 
static bool _absEqual (const Integer &l, const Integer &r)
 Examine if l == r. More...
 
static bool _isZero (const Integer &l)
 

Protected Attributes

Storage::Interface_idata = nullptr
 
bool _idata_ar = false
 
bool _isPostive = true
 

Friends

std::ostream & operator<< (std::ostream &os, Integer &rhs)
 Reload of operator<< to support std::cout and other std::ostream with Integer. More...
 
std::istream & operator>> (std::istream &is, Integer &rhs)
 Reload of operator>> to support std::cin and other std::istream with Integer. More...
 

Detailed Description

Integer type.

A storage class pointer is needed to construct object. Besides, a static defined construction function is provided.

Definition at line 27 of file Value.hpp.

Constructor & Destructor Documentation

◆ Integer() [1/3]

HRCore::Value::Integer::Integer ( Storage::Interface ptr,
bool  positive = true,
bool  autoRelease = false,
bool  sim = true 
)
inline

Construct a new Integer object.

Parameters
ptrA pointer to a object of a class that implemented Storage::Interface
positiveDecide whether the Integer object is positive or negative
autoReleaseSpecify if the ptr should be release autonomously after deconstruction
simDecide if the data should be simplified first. (Internally)
Exceptions
-1when the ptr is invalid.
Here is an example:
ChainList<8> sto;
Integer a(&sto);
Integer type.
Definition: Value.hpp:27
Note
The Storage::Interface implemented object should NOT be destroyed before destruction of object of this class.
Exceptions
Exception::InvalidArgumentis throw when ptr is nullptr

Definition at line 84 of file Value.hpp.

Here is the call graph for this function:

◆ Integer() [2/3]

HRCore::Value::Integer::Integer ( Integer &&  c)
inline

Move a Integer object.

Parameters
cThe Integer object to be moved

Definition at line 125 of file Value.hpp.

◆ Integer() [3/3]

HRCore::Value::Integer::Integer ( const Integer c)
inline

Copy and construct a new Integer object.

Note
The internal data type is decided by parameter c!
Parameters
cPrevious Integer object to be copied.

Definition at line 159 of file Value.hpp.

Here is the call graph for this function:

◆ ~Integer()

HRCore::Value::Integer::~Integer ( )
inline

Definition at line 171 of file Value.hpp.

Member Function Documentation

◆ _absEqual()

static bool HRCore::Value::Integer::_absEqual ( const Integer l,
const Integer r 
)
inlinestaticprotected

Examine if l == r.

Definition at line 513 of file Value.hpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ _absGreater()

static bool HRCore::Value::Integer::_absGreater ( const Integer l,
const Integer r 
)
inlinestaticprotected

Examine if l > r.

Definition at line 510 of file Value.hpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ _absRelation()

static int8_t HRCore::Value::Integer::_absRelation ( const Integer l,
const Integer r 
)
inlinestaticprotected

Get relation of l and r.

Returns
int8_t -1 when l < r, 0 when l = r, and 1 when l > r

Definition at line 490 of file Value.hpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ _isZero()

static bool HRCore::Value::Integer::_isZero ( const Integer l)
inlinestaticprotected

Definition at line 515 of file Value.hpp.

◆ divideBy()

DivisionResult_t HRCore::Value::Integer::divideBy ( const Integer r)
inline

A function to calculate (*this / r)

Returns
DivisionResult_t
Todo:
FFT implement

Definition at line 279 of file Value.hpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ make() [1/2]

template<typename T >
static Integer HRCore::Value::Integer::make ( )
inlinestatic

Construct a new Integer object using given type of Storage::Interface implement.

Template Parameters
TType of Storage::Interface implement
Returns
Integer New object
Here is a example:
Integer&& it = Integer::make<Storage::LinkedList<8>>();

Definition at line 109 of file Value.hpp.

Here is the caller graph for this function:

◆ make() [2/2]

Integer HRCore::Value::Integer::make ( )
inline

Make a new object with same Interface type.

Definition at line 115 of file Value.hpp.

Here is the call graph for this function:

◆ operator%()

Integer HRCore::Value::Integer::operator% ( const Integer r)
inline

Reload of operator%.

Parameters
rThe number to divide
Returns
Integer Value of (this % r)

Definition at line 357 of file Value.hpp.

Here is the call graph for this function:

◆ operator*()

Integer HRCore::Value::Integer::operator* ( const Integer r)
inline

Reload of operator*(r)

Parameters
rThe number to mutiply
Returns
Integer Value of ( this * r )
Todo:
FFT implement

Definition at line 246 of file Value.hpp.

Here is the call graph for this function:

◆ operator+() [1/2]

Integer HRCore::Value::Integer::operator+ ( ) const
inline

Reload of operator+() const.

Definition at line 377 of file Value.hpp.

Here is the caller graph for this function:

◆ operator+() [2/2]

Integer HRCore::Value::Integer::operator+ ( const Integer r)
inline

Reload of operator+.

Parameters
rThe value of right side
Returns
Integer The result of (this + r)

Definition at line 210 of file Value.hpp.

Here is the call graph for this function:

◆ operator-() [1/2]

Integer HRCore::Value::Integer::operator- ( ) const
inline

Reload of operator-() const.

Definition at line 367 of file Value.hpp.

◆ operator-() [2/2]

Integer HRCore::Value::Integer::operator- ( const Integer r)
inline

Reload of operator-(r)

Parameters
rThe value of right side
Returns
Integer The result of (this - r)

Definition at line 236 of file Value.hpp.

Here is the call graph for this function:

◆ operator/()

Integer HRCore::Value::Integer::operator/ ( const Integer r)
inline

Reload of operator/.

Parameters
rThe number to divide
Returns
Integer Value of (this / r)

Definition at line 344 of file Value.hpp.

Here is the call graph for this function:

◆ operator<()

bool HRCore::Value::Integer::operator< ( const Integer r)
inline

Compare this and r with operator <.

Parameters
rThe number to be put in the right side to compare
Returns
bool (this < r)

Definition at line 394 of file Value.hpp.

Here is the call graph for this function:

◆ operator<<()

Integer HRCore::Value::Integer::operator<< ( size_t  n)
inline

Reload of << (Left shift)

Parameters
nBits to shift
Returns
Integer Result of (this << n)

Definition at line 434 of file Value.hpp.

Here is the call graph for this function:

◆ operator<=()

bool HRCore::Value::Integer::operator<= ( const Integer r)
inline

Test if (this <= r)

Definition at line 426 of file Value.hpp.

◆ operator=() [1/3]

Integer & HRCore::Value::Integer::operator= ( const Integer c)
inline

Copy operator.

Definition at line 198 of file Value.hpp.

◆ operator=() [2/3]

Integer & HRCore::Value::Integer::operator= ( Integer &&  c)
inline

Move operator.

Parameters
cThe Integer object to be moved
Returns
Integer& Left-value reference of moved object

Definition at line 142 of file Value.hpp.

Here is the caller graph for this function:

◆ operator=() [3/3]

Integer & HRCore::Value::Integer::operator= ( ival_t  num)
inline

Reload of operator= to support a ival_t be converted to Integer.

Parameters
numValue to be converted
Returns
Integer& Return of converted object

Definition at line 185 of file Value.hpp.

Here is the call graph for this function:

◆ operator==()

bool HRCore::Value::Integer::operator== ( const Integer r)
inline

Test if (r == this)

Definition at line 415 of file Value.hpp.

Here is the call graph for this function:

◆ operator>()

bool HRCore::Value::Integer::operator> ( const Integer r)
inline

Compare this and r with operator >

Parameters
rThe number to be put in the right side
Returns
bool (this > r)

Definition at line 407 of file Value.hpp.

Here is the call graph for this function:

◆ operator>=()

bool HRCore::Value::Integer::operator>= ( const Integer r)
inline

Test if (this >= r)

Definition at line 423 of file Value.hpp.

◆ operator>>()

Integer HRCore::Value::Integer::operator>> ( size_t  n)
inline

Reload of >> (Logical right shift)

Parameters
nBits to shift
Returns
Integer Result of (this >> n)

Definition at line 460 of file Value.hpp.

Here is the call graph for this function:

◆ positive() [1/2]

bool HRCore::Value::Integer::positive ( ) const
inline

Return the sign of object.

Definition at line 380 of file Value.hpp.

Here is the caller graph for this function:

◆ positive() [2/2]

void HRCore::Value::Integer::positive ( bool  p)
inline

Set the sign of object.

Parameters
pWhether positive is true or false

Definition at line 386 of file Value.hpp.

Friends And Related Function Documentation

◆ operator<<

std::ostream & operator<< ( std::ostream &  os,
Integer rhs 
)
friend

Reload of operator<< to support std::cout and other std::ostream with Integer.

Example:

auto a = Integer::make<LinkedList<8>>();
cout << a;
Note
When std::hex flag is not set, Dec number is output by default.

Definition at line 56 of file Utils.hpp.

◆ operator>>

std::istream & operator>> ( std::istream &  is,
Integer rhs 
)
friend

Reload of operator>> to support std::cin and other std::istream with Integer.

Example:

auto a = Integer::make<LinkedList<8>>();
cin >> a;

Definition at line 119 of file Utils.hpp.

Member Data Documentation

◆ _idata

Storage::Interface* HRCore::Value::Integer::_idata = nullptr
protected

Definition at line 622 of file Value.hpp.

◆ _idata_ar

bool HRCore::Value::Integer::_idata_ar = false
protected

Definition at line 623 of file Value.hpp.

◆ _isPostive

bool HRCore::Value::Integer::_isPostive = true
protected

Definition at line 624 of file Value.hpp.


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