OverSim
SimpleCoordinate Class Reference

.h More...

#include <SimpleCoordDataContainer.h>

Classes

class  hashFcn
 defines a hash function for SimpleCoordinate More...

Public Member Functions

 SimpleCoordinate ()
virtual ~SimpleCoordinate ()
bool operator< (const SimpleCoordinate &compSimpleCoordinate) const
 comapares this to a given coordinate
bool operator> (const SimpleCoordinate &compSimpleCoordinate) const
 comapares this to a given coordinate
bool operator== (const SimpleCoordinate &compSimpleCoordinate) const
 comapares this to a given coordinate
size_t hash () const
 returns a hash value

Public Attributes

std::vector< int > coordData

Protected Member Functions

int compareTo (const SimpleCoordinate &compSimpleCoordinate) const
 Unifies all compare operations in one method.

Detailed Description

.h

Author
Daniel Lienert

Definition at line 32 of file SimpleCoordDataContainer.h.

Constructor & Destructor Documentation

SimpleCoordinate::SimpleCoordinate ( )

Definition at line 53 of file SimpleCoordDataContainer.cc.

{
// TODO Auto-generated constructor stub
}
SimpleCoordinate::~SimpleCoordinate ( )
virtual

Definition at line 58 of file SimpleCoordDataContainer.cc.

{
// TODO Auto-generated destructor stub
}

Member Function Documentation

int SimpleCoordinate::compareTo ( const SimpleCoordinate compSimpleCoordinate) const
protected

Unifies all compare operations in one method.

Parameters
compSimpleCoordinatesimpleCoord to compare with
Returns
int -1 if smaller, 0 if equal, 1 if greater

Definition at line 62 of file SimpleCoordDataContainer.cc.

Referenced by operator<(), operator==(), and operator>().

{
std::vector<int> compCoord = compSimpleCoordinate.coordData;
if(coordData.size() != compCoord.size()) {
throw std::exception();
}
for(unsigned int i = 0; i < coordData.size(); i++) {
if(coordData[i] < compCoord[i]) return -1;
if(coordData[i] > compCoord[i]) return 1;
}
return 0;
}
size_t SimpleCoordinate::hash ( ) const

returns a hash value

Definition at line 78 of file SimpleCoordDataContainer.cc.

Referenced by SimpleCoordinate::hashFcn::operator()().

{
long hashValue = 0;
for(unsigned int i = 0; i < coordData.size(); i++) {
hashValue += pow(coordData[i],i);
}
return (size_t)hashValue;
}
bool SimpleCoordinate::operator< ( const SimpleCoordinate compSimpleCoordinate) const

comapares this to a given coordinate

Parameters
compSimpleCoordinateSimpleCoordinate to compare to

Definition at line 89 of file SimpleCoordDataContainer.cc.

{
return compareTo(compSimpleCoordinate) == -1;
}
bool SimpleCoordinate::operator== ( const SimpleCoordinate compSimpleCoordinate) const

comapares this to a given coordinate

Parameters
compSimpleCoordinateSimpleCoordinate to compare to

Definition at line 97 of file SimpleCoordDataContainer.cc.

{
return compareTo(compSimpleCoordinate) == 0;
}
bool SimpleCoordinate::operator> ( const SimpleCoordinate compSimpleCoordinate) const

comapares this to a given coordinate

Parameters
compSimpleCoordinateSimpleCoordinate to compare to

Definition at line 93 of file SimpleCoordDataContainer.cc.

{
return compareTo(compSimpleCoordinate) == 1;
}

Member Data Documentation

std::vector<int> SimpleCoordinate::coordData

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