User:Timothee Flutre/Notebook/Postdoc/2011/11/21

From OpenWetWare

Jump to: navigation, search
Project name Main project page
Previous entry      Next entry

Entry title

  • dealing with missing values in C++ for type "double" (eg. missing measurements):
#include <limits>
using namespace std;
...
vector<double> vSummaryStats (n, numeric_limits<double>::quiet_NaN());
...  // fill this vector
if (! isnan(vSummaryStats[i]))
  ...
  • dealing with missing values in C++ for type "size_t" (eg. stream positions of an item in a set of files): use string::npos as it is impossible to use -1 (size_t is unsigned...) and as we don't know what is the max possible value
#include <string>
using namespace std;
...
int nbFiles = 4;
map<string, vector<size_t> > mItemName2StreamPositions;
...  // fill this map
for(it = mItemName2StreamPositions.begin(); it < ...)
  for (j = 0; j < nbFiles; ++j)
    if (it->second[j] == string::npos)
      ...



Personal tools