00001 #pragma once
00002 #include <vector>
00003 #include <string>
00004 #include <iostream>
00005
00006 class Rec
00007 {
00008 public:
00009 float prob;
00010 std::string line;
00011
00012 Rec(float aprob, const std::string &aline)
00013 :prob(aprob)
00014 ,line(aline)
00015 {}
00016
00017 inline bool operator< (const Rec &compare) const {
00018 return prob < compare.prob;
00019 }
00020 };
00021
00023
00024 void Process(int limit, std::istream &inStrme, std::ostream &outStrme);
00025 void Output(std::ostream &outStrme, std::vector<Rec> &records, int limit);
00026
00028 inline void Tokenize(std::vector<std::string> &output
00029 , const std::string& str
00030 , const std::string& delimiters = " \t")
00031 {
00032
00033 std::string::size_type lastPos = str.find_first_not_of(delimiters, 0);
00034
00035 std::string::size_type pos = str.find_first_of(delimiters, lastPos);
00036
00037 while (std::string::npos != pos || std::string::npos != lastPos) {
00038
00039 output.push_back(str.substr(lastPos, pos - lastPos));
00040
00041 lastPos = str.find_first_not_of(delimiters, pos);
00042
00043 pos = str.find_first_of(delimiters, lastPos);
00044 }
00045 }
00046