Beispiel #1
0
id_t DataSet::Read (const char *file_name)
{
  std::ifstream ifs (file_name);
  std::string line;
  id_t max_id = 0;
  int line_count = 0;

  while (getline (ifs, line))
  {
    line_count++;
    SparseVector temp;
    const char *pos = sdf_parse_line (line.c_str (), temp);
    if (*pos && (*pos != '#'))
    {
      FATAL << "Error in input:" << line_count << ':' 
        << pos - line.c_str () + 1 << std::endl; 
      return 0;
    }
    data_set_.push_back (temp);
    if (temp.max_id () > max_id)
      max_id = temp.max_id ();
  }   
  return max_id;
}