Changeset 723


Ignore:
Timestamp:
Jan 1, 2007, 4:58:01 PM (15 years ago)
Author:
Jari Häkkinen
Message:

Fixes #10. Removed read_to*(std::vector..) functionality.

Location:
trunk
Files:
2 deleted
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/test/Makefile.am

    r710 r723  
    3030  kernel_test kernel_lookup_test matrix_test matrix_lookup_test       \
    3131  ncc_test nni_test pca_test regression_test rnd_test score_test      \
    32   statistics_test stl_utility_test subset_generator_test svd_test     \
    33   svm_test target_test utility_test vector_test
     32  statistics_test subset_generator_test svd_test svm_test target_test \
     33  utility_test vector_test
    3434
    3535check_PROGRAMS = $(TESTS)
     
    6262score_test_SOURCES = score_test.cc
    6363statistics_test_SOURCES = statistics_test.cc
    64 stl_utility_test_SOURCES = stl_utility_test.cc
    6564subset_generator_test_SOURCES = subset_generator_test.cc
    6665svd_test_SOURCES = svd_test.cc
  • trunk/yat/utility/stl_utility.cc

    r715 r723  
    33/*
    44  Copyright (C) 2005 Jari Häkkinen, Peter Johansson, Markus Ringnér
    5   Copyright (C) 2006 Jari Häkkinen
     5  Copyright (C) 2006, 2007 Jari Häkkinen
    66
    77  This file is part of the yat library, http://lev.thep.lu.se/trac/yat
     
    3636namespace utility {
    3737
    38   bool read_to_double(std::istream& is, std::vector<double>& vec)
    39   {
    40     vec.resize(0);
    41     std::vector<std::string> vec_str;
    42     if (read_to_string(is,vec_str)){
    43       for (size_t i=0; i<vec_str.size(); i++) {
    44         if (is_double(vec_str[i])) {
    45           vec.push_back(atof(vec_str[i].c_str()));
    46         }
    47         else if (is_nan(vec_str[i])) {
    48           vec.push_back(std::numeric_limits<double>::quiet_NaN());
    49         }
    50         else {
    51           // Jari, this should be communicated with as an exception.
    52           //          std::cerr << "Warning: '" << vec_str[i]
    53           //                    << "' is not a number." << std::endl;
    54         }
    55       }
    56       return true;
    57     }
    58     else
    59       return false;
    60   }
    61 
    62 
    63   bool read_to_int(std::istream& is, std::vector<int>& vec)
    64   {
    65     vec.resize(0);
    66     std::vector<std::string> vec_str;
    67     if (read_to_string(is,vec_str)){
    68       for (size_t i=0; i<vec_str.size(); i++) {
    69         if (is_int(vec_str[i])) {
    70           vec.push_back(atoi(vec_str[i].c_str()));
    71         }
    72         else if (is_nan(vec_str[i])) {
    73           vec.push_back(std::numeric_limits<int>::quiet_NaN());
    74         }
    75         else {
    76           // Jari, this should be communicated with as an exception.
    77           //          std::cerr << "Warning: '" << vec_str[i]
    78           //                    << "' is not an integer." << std::endl;
    79         }
    80       }
    81       return true;
    82     }
    83     else
    84       return false;
    85   }
    86 
    87 
    88   bool read_to_string(std::istream& is, std::vector<std::string>& vec)
    89   {
    90     vec.resize(0);
    91     std::string s;
    92     if (getline(is, s, '\n')){
    93       std::istringstream line(s);
    94       std::string tmp_string;
    95       while (line >> tmp_string)
    96         vec.push_back(tmp_string);
    97       return true;
    98     }
    99     else
    100       return false;
    101   }
    102 
    103 
    10438  void to_lower(std::string& s)
    10539  {
  • trunk/yat/utility/stl_utility.h

    r715 r723  
    77  Copyright (C) 2004 Jari Häkkinen
    88  Copyright (C) 2005 Jari Häkkinen, Peter Johansson, Markus Ringnér
    9   Copyright (C) 2006 Jari Häkkinen
     9  Copyright (C) 2006, 2007 Jari Häkkinen
    1010
    1111  This file is part of the yat library, http://lev.thep.lu.se/trac/yat
     
    7878
    7979  ///
    80   /// Function reading from istream to vector of doubles. Function
    81   /// reads the line until next '\\n'. The line is splitted with
    82   /// respect to whitespaces and push_backed into the vector. The
    83   /// vector is emptied before the reading starts. Unexpected
    84   /// characters are currently skipped with a warning message.
    85   /// NaN is supported to be a double (case-insensitive)
    86   ///
    87   /// @return false if end of stream
    88   ///
    89   /// @note The functionality of this function will change in the
    90   /// future. The overall functionality will be the same but the
    91   /// outcome of unexpected events will change.
    92   ///
    93   bool read_to_double(std::istream&, std::vector<double>&);
    94 
    95   ///
    96   /// Function reading from istream to vector of ints. Function
    97   /// reads the line until next '\\n'. The line is splitted with
    98   /// respect to whitespaces and push_backed into the vector. The
    99   /// vector is emptied before the reading starts. Unexpected
    100   /// characters are currently skipped with a warning message.
    101   /// NaN is supported to be an int (case-insensitive)
    102   ///
    103   /// @return false if end of stream
    104   ///
    105   /// @note The functionality of this function will change in the
    106   /// future. The overall functionality will be the same but the
    107   /// outcome of unexpected events will change.
    108   ///
    109   bool read_to_int(std::istream&, std::vector<int>&);
    110 
    111   ///
    112   /// Function reading from istream to vector of strings. Function
    113   /// reads the line until next '\\n'. The line is splitted with
    114   /// respect to whitespaces and push_backed into the vector. The
    115   /// vector is emptied before the reading starts.
    116   ///
    117   /// @return false if end of stream
    118   ///
    119   bool read_to_string(std::istream&, std::vector<std::string>&);
    120 
    121   ///
    12280  /// @brief Function converting a string to lower case
    12381  ///
Note: See TracChangeset for help on using the changeset viewer.