00001
00010 #ifndef _NODE_AND_VALUES_H_
00011 #define _NODE_AND_VALUES_H_
00012
00013 #include "TreeNode.h"
00014
00015 namespace ot {
00016
00023 template<typename T, unsigned int ARR_LEN>
00024 class NodeAndValues {
00025 public:
00026
00027 ot::TreeNode node;
00028 T values[ARR_LEN];
00032 bool Equals(NodeAndValues<T, ARR_LEN> const & other) const {
00033 bool result = ((this->node) == other.node);
00034
00035 for(unsigned int i = 0; (i < ARR_LEN) && result; i++) {
00036 result = ( (this->values[i]) == (other.values[i]) );
00037 }
00038
00039 return result;
00040 }
00041
00042 bool operator == ( NodeAndValues<T, ARR_LEN> const & other) const{
00043 return ((this->node) == other.node);
00044 }
00045
00046 bool operator != ( NodeAndValues<T, ARR_LEN> const & other) const{
00047 return ((this->node) != other.node);
00048 }
00049
00050 bool operator < ( NodeAndValues<T, ARR_LEN> const & other) const{
00051 return ((this->node) < other.node);
00052 }
00053
00054 bool operator <= ( NodeAndValues<T, ARR_LEN> const & other) const{
00055 return ((this->node) <= other.node);
00056 }
00057
00058 bool operator > ( NodeAndValues<T, ARR_LEN> const & other) const{
00059 return ((this->node) > other.node);
00060 }
00061
00062 bool operator >= ( NodeAndValues<T, ARR_LEN> const & other) const{
00063 return ((this->node) >= other.node);
00064 }
00065
00066
00067 NodeAndValues<T, ARR_LEN>& operator = ( NodeAndValues<T, ARR_LEN> const & other) {
00068 if(this == (&other)) {return *this;}
00069 this->node = other.node;
00070 for(unsigned int i = 0; i < ARR_LEN; i++) {
00071 this->values[i] = other.values[i];
00072 }
00073 return *this;
00074 }
00075
00077
00080 NodeAndValues () { }
00081
00082
00083 NodeAndValues (const NodeAndValues<T, ARR_LEN> & other) {
00084 this->node = other.node;
00085 for(unsigned int i = 0; i < ARR_LEN; i++) {
00086 this->values[i] = other.values[i];
00087 }
00088 }
00090
00091 };
00092
00093 }
00094
00095 namespace par {
00096
00097
00098 template <typename T>
00099 class Mpi_datatype;
00100
00106 template <typename T, unsigned int ARR_LEN>
00107 class Mpi_datatype< ot::NodeAndValues<T, ARR_LEN> > {
00108
00109 public:
00110
00114 static MPI_Datatype value()
00115 {
00116 static bool first = true;
00117 static MPI_Datatype datatype;
00118
00119 if (first)
00120 {
00121 first = false;
00122 MPI_Type_contiguous(sizeof(ot::NodeAndValues<T, ARR_LEN>), MPI_BYTE, &datatype);
00123 MPI_Type_commit(&datatype);
00124 }
00125
00126 return datatype;
00127 }
00128
00129 };
00130
00131 }
00132
00133
00134 #endif
00135
00136