The Original CHomP Software
Public Member Functions | Private Attributes | Friends | List of all members
chomp::homology::diGraph< wType >::posWeight Class Reference

A class for representing a positive number with negative values serving as the infinity (used in the Dijkstra algorithm). More...

Public Member Functions

 posWeight ()
 The default constructor. More...
 
 posWeight (const wType &_value)
 An optional constructor. More...
 
void setInfinity ()
 Sets the value to the infinity. More...
 
bool isInfinity () const
 Returns true iff the value corresponds to the infinity. More...
 
const wType & getValue () const
 Returns the value stored in this object. More...
 

Private Attributes

wType value
 The actual number. More...
 

Friends

bool operator< (const posWeight &x, const posWeight &y)
 The < operator for comparing the numbers. More...
 
std::ostream & operator<< (std::ostream &out, const posWeight &x)
 The operator for showing the number to the output stream. More...
 

Detailed Description

template<class wType = int>
class chomp::homology::diGraph< wType >::posWeight

A class for representing a positive number with negative values serving as the infinity (used in the Dijkstra algorithm).

Definition at line 514 of file digraph.h.

Constructor & Destructor Documentation

◆ posWeight() [1/2]

template<class wType = int>
chomp::homology::diGraph< wType >::posWeight::posWeight ( )
inline

The default constructor.

Definition at line 518 of file digraph.h.

519 {
520 value = 0;
521 return;
522 }
wType value
The actual number.
Definition: digraph.h:577

References chomp::homology::diGraph< wType >::posWeight::value.

◆ posWeight() [2/2]

template<class wType = int>
chomp::homology::diGraph< wType >::posWeight::posWeight ( const wType &  _value)
inlineexplicit

An optional constructor.

Definition at line 525 of file digraph.h.

526 {
527 if (_value < 0)
528 value = 0;
529 else
530 value = _value;
531 return;
532 }

References chomp::homology::diGraph< wType >::posWeight::value.

Member Function Documentation

◆ getValue()

template<class wType = int>
const wType & chomp::homology::diGraph< wType >::posWeight::getValue ( ) const
inline

Returns the value stored in this object.

Definition at line 548 of file digraph.h.

549 {
550 return value;
551 }

References chomp::homology::diGraph< wType >::posWeight::value.

◆ isInfinity()

template<class wType = int>
bool chomp::homology::diGraph< wType >::posWeight::isInfinity ( ) const
inline

Returns true iff the value corresponds to the infinity.

Definition at line 542 of file digraph.h.

543 {
544 return (value < 0);
545 }

References chomp::homology::diGraph< wType >::posWeight::value.

◆ setInfinity()

template<class wType = int>
void chomp::homology::diGraph< wType >::posWeight::setInfinity ( )
inline

Sets the value to the infinity.

Definition at line 535 of file digraph.h.

536 {
537 value = -1;
538 return;
539 }

References chomp::homology::diGraph< wType >::posWeight::value.

Friends And Related Function Documentation

◆ operator<

template<class wType = int>
bool operator< ( const posWeight x,
const posWeight y 
)
friend

The < operator for comparing the numbers.

Definition at line 554 of file digraph.h.

556 {
557 if (y. isInfinity ())
558 return !(x. isInfinity ());
559 else if (x. isInfinity ())
560 return false;
561 return (x. value < y. value);
562 }
bool isInfinity() const
Returns true iff the value corresponds to the infinity.
Definition: digraph.h:542

◆ operator<<

template<class wType = int>
std::ostream & operator<< ( std::ostream &  out,
const posWeight x 
)
friend

The operator for showing the number to the output stream.

Definition at line 565 of file digraph.h.

567 {
568 if (x. isInfinity ())
569 out << "+oo";
570 else
571 out << x. getValue ();
572 return out;
573 }
const wType & getValue() const
Returns the value stored in this object.
Definition: digraph.h:548

Member Data Documentation

◆ value

template<class wType = int>
wType chomp::homology::diGraph< wType >::posWeight::value
private

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