Exemplo n.º 1
0
	const string_list& track_info::get_language_codes()
	{
		static string_list languageCodes;
		if ( languageCodes.size() == 0 ) {
			languageCodes.resize( language_count );
			transform( language_code_map, language_code_map + language_count, languageCodes.begin(),
					   bind( &alpha_pair::second, _1 ) );
			languageCodes.erase( unique( languageCodes.begin(), languageCodes.end() ), languageCodes.end() );
		}
		return languageCodes;
	}
void benchmark_summary::write_data_files(const string_list& ops) const
{
  typedef std::vector<std::string> string_list;
  for (string_list::const_iterator op = ops.begin(); op != ops.end(); ++op)
  {
    if (!results_for_op_exist(op))
      continue;

    const std::string filename(std::string(to_string(op)) + ".dat");
    std::ofstream file(filename.c_str());
    if (!file.is_open())
      throw std::runtime_error("couldn't open data file");

    const unsigned int num_ops = results.count(op);
    const_result_iterator first = results.lower_bound(op);
    const_result_iterator last = results.upper_bound(op);

    for (unsigned int i = 0; i < num_input_samples_; ++i)
    {
      while (first != last)
      {
        file << first->ops.at(i);
        
        if (++first != last)
          file << "\t";
      }
      file << "\n";
    }
  }
}
Exemplo n.º 3
0
bool string_list::compare(const string_list& list, bool cs) const {
    if(size() != list.size()) {
        return false;
    }

    const_iterator i1 = begin();
    const_iterator i2 = list.begin();
    while(i1 != end() || i2 != list.end()) {
        if( i1->compare(*i2, 0, string::npos, cs) != 0 ) {
            return false;
        }
        i1++;
        i2++;
    }
    return true;
}
Exemplo n.º 4
0
const std::string decode_mnemonic(const string_list& words)
{
    std::ostringstream ss;
    ss << std::hex;
    auto words_end = words.end() - words.size() % 3;
    std::cout << std::endl;
    for (auto it = words.begin(); it != words_end; it += 3)
    {
        const int n = (int)common_words.size();
        int index_1 = (int)index_of(*it);
        int index_2 = (int)index_of(*(it + 1)) % n;
        int index_3 = (int)index_of(*(it + 2)) % n;
        uint32_t val = index_1 +
            n * special_modulo(index_2 - index_1, n) +
            n * n * special_modulo(index_3 - index_2, n);
        ss << val;
    }
    return ss.str();
}
Exemplo n.º 5
0
inline string_list::const_iterator begin(const string_list &list) {
  return list.begin();
}