当前位置: 首页>>代码示例>>C++>>正文


C++ std::equal方法代码示例

本文整理汇总了C++中std::equal方法的典型用法代码示例。如果您正苦于以下问题:C++ std::equal方法的具体用法?C++ std::equal怎么用?C++ std::equal使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在std的用法示例。


在下文中一共展示了std::equal方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: get_paths_from_dir

bool sensor_plugin_loader::get_paths_from_dir(const string &dir_path, vector<string> &hal_paths, vector<string> &sensor_paths)
{
	const string PLUGIN_POSTFIX = ".so";
	const string HAL_POSTFIX = "_hal.so";

	DIR *dir = NULL;
	struct dirent *dir_entry = NULL;

	dir = opendir(dir_path.c_str());

	if (!dir) {
		ERR("Failed to open dir: %s", dir_path.c_str());
		return false;
	}

	string name;

	while (dir_entry = readdir(dir)) {
		name = string(dir_entry->d_name);

		if (equal(PLUGIN_POSTFIX.rbegin(), PLUGIN_POSTFIX.rend(), name.rbegin())) {
			if (equal(HAL_POSTFIX.rbegin(), HAL_POSTFIX.rend(), name.rbegin()))
				hal_paths.push_back(dir_path + "/" + name);
			else
				sensor_paths.push_back(dir_path + "/" + name);
		}
	}

	closedir(dir);
	return true;
}
开发者ID:Biktorgj,项目名称:android_device_samsung_pontesolo,代码行数:31,代码来源:sensor_plugin_loader.cpp

示例2: main

int main(int argc, char* argv[]) {
  //      3
  //    2   5
  //  1    4 6
  unique_ptr<BinaryTreeNode<int>> root = unique_ptr<BinaryTreeNode<int>>(
      new BinaryTreeNode<int>{3, nullptr, nullptr});
  root->left = unique_ptr<BinaryTreeNode<int>>(
      new BinaryTreeNode<int>{2, nullptr, nullptr});
  root->left->left = unique_ptr<BinaryTreeNode<int>>(
      new BinaryTreeNode<int>{1, nullptr, nullptr});
  root->right = unique_ptr<BinaryTreeNode<int>>(
      new BinaryTreeNode<int>{5, nullptr, nullptr});
  root->right->left = unique_ptr<BinaryTreeNode<int>>(
      new BinaryTreeNode<int>{4, nullptr, nullptr});
  root->right->right = unique_ptr<BinaryTreeNode<int>>(
      new BinaryTreeNode<int>{6, nullptr, nullptr});
  // should output 3
  //               2 5
  //               1 4 6
  PrintBinaryTreeDepthOrder(root);
  vector<vector<int>> golden_res = {{3}, {2, 5}, {1, 4, 6}};
  assert(golden_res.size() == results.size() &&
         equal(golden_res.begin(), golden_res.end(), results.begin()));
  return 0;
}
开发者ID:JohnKurlak,项目名称:epibook.github.io,代码行数:25,代码来源:Binary_tree_level_order.cpp

示例3: test

void MorphemeDisambiguatorClass::test(const string &testFilename) const {
    ifstream ifs(testFilename);

    size_t correctCount = 0;
    size_t allCount = 0;
    while (true) {
        vector<string> sequence = Utility::readSequence(ifs);
        if (!ifs) {
            break;
        }
        vector<string> sentence;
        vector<vector<string>> correctResultList;
        splitSentenceAndResult(sequence, &sentence, &correctResultList);
        auto inferredResultList = tag(sentence);
        assert(inferredResultList.size() == correctResultList.size());
        for (size_t i = 0; i < inferredResultList.size(); ++i) {
            if (inferredResultList[i].size() == correctResultList[i].size() + 2 &&
                equal(inferredResultList[i].begin() + 2, inferredResultList[i].end(), correctResultList[i].begin())) {
                ++correctCount;
            }
            ++allCount;
        }
    }
    ifs.close();
    printf("Accuracy: %d / %d (%1.4f)\n", correctCount, allCount, correctCount / (double)allCount);
}
开发者ID:hiroshi-manabe,项目名称:CRFSegmenter,代码行数:26,代码来源:MorphemeDisambiguatorClass.cpp

示例4: apply

 static bool apply(alps::numeric::matrix<T,MemoryBlock> const& m) {
     typedef typename alps::numeric::matrix<T,MemoryBlock>::const_col_element_iterator col_iterator;
     using alps::hdf5::get_extent;
     using alps::hdf5::is_vectorizable;
     using std::equal;
     if(boost::is_scalar<typename alps::numeric::matrix<T,MemoryBlock>::value_type>::value || m.empty())
         return true;
     else {
         std::vector<std::size_t> first_element_extent(get_extent(m(0,0)));
         for(std::size_t j=0; j < num_cols(m); ++j) {
             for(std::pair<col_iterator,col_iterator> r = col(m,j); r.first != r.second; ++r.first) {
                 if(!is_vectorizable(*r.first)) {
                     return false;
                 } else {
                     std::vector<std::size_t> element_extent(get_extent(*r.first));
                     if(
                         first_element_extent.size() != element_extent.size()
                         || !equal(first_element_extent.begin(), first_element_extent.end(), element_extent.begin())
                     )
                         return false;
                 }
             }
         }
         return true;
     }
 }
开发者ID:ryanlevy,项目名称:ALPSCore,代码行数:26,代码来源:matrix.hpp

示例5: src

END_TEST

START_TEST(should_overwrite_destination_file)
{
	Process_dir_fixture f;
	string src(f.get_path() + "/src");
	create_emptyfile(src);
	vector<char> content(dummy_content());
	write_to_file(src, content);
	vector<char> dest_content(content);
	dest_content.insert(dest_content.end(), content.begin(), content.end());
	random_shuffle(dest_content.begin(), dest_content.end());
	string dest(f.get_path() + "/dest");
	write_to_file(dest, dest_content);

	Io io;
	int r(copy(io, src.c_str(), dest.c_str()));

	fail_unless(r == 0, "result value");
	vector<char> copied;
	read_file(dest, copied);
	fail_unless(content.size() == copied.size(), "size");
	fail_unless(equal(content.begin(), content.end(), copied.begin()),
		"value");
}
开发者ID:sugawaray,项目名称:filemanager,代码行数:25,代码来源:copy.cpp

示例6: is_palindrome

inline bool is_palindrome(string word) { return equal(word.begin(), word.end(), word.rbegin()); }
开发者ID:adamcavendish,项目名称:HomeworkGitShare,代码行数:1,代码来源:05palindrome.cpp

示例7: is_palindrome

bool is_palindrome(const string& s)
{
  return equal(s.begin(), s.end(), s.rbegin());
}
开发者ID:JesseLiu0,项目名称:coursework,代码行数:4,代码来源:palin.cpp


注:本文中的std::equal方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。