00001
00002
00003 #ifndef ML_ALGORITHM_PRINT_HPP
00004 #define ML_ALGORITHM_PRINT_HPP
00005
00006 #include <ostream>
00007 #include <iterator>
00008 #include <algorithm>
00009
00010 namespace ml_algorithm {
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 template <typename T, typename InputOperator>
00021 std::ostream& print(InputOperator first, InputOperator last, std::ostream& os, const char* delim)
00022 {
00023 std::copy(first, last, std::ostream_iterator<T>(os, delim));
00024 return os;
00025 }
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036 template <typename T, typename InputOperator, typename UnaryFunction>
00037 std::ostream& print(InputOperator first, InputOperator last, std::ostream& os, const char* delim, UnaryFunction op)
00038 {
00039 std::transform(first, last, std::ostream_iterator<T>(os, delim), op);
00040 return os;
00041 }
00042 }
00043
00044 #endif
00045