ICode9

精准搜索请尝试: 精确搜索
  • c-在容器中使用n_th元素,但使用另一个键2019-10-13 22:15:51

    我有两个向量.一种实际上保存数据(比如说是浮点数),另一种保存索引.我想在nth_element处传递索引向量,但我希望通过实际保存数据的向量来进行比较.我当时在考虑函子,但这只提供了我猜想的()运算符.我通过使数据向量成为全局向量来实现这一点,但这当然是不希望的. std::vector<floa

  • c-根据另一个向量对点向量进行排序2019-10-10 16:11:25

    我正在开发C应用程序. 我有2个点向量 vector<Point2f> vectorAll; vector<Point2f> vectorSpecial; Point2f被定义为typedef Point_< float>. Point2f; vectorAll有1000点,而vectorSpecial有10点. 第一步: 我需要根据vectorAll中的顺序对这些点进行排序. 所以像这样: For each P

  • c – std :: includes实际上做了什么?2019-10-05 05:16:03

    从the standard, std ::包括: Returns: true if [first2, last2) is empty or if every element in the range [first2, last2) is contained in the range [first1, last1). Returns false otherwise. 注意:由于这是在[alg.set.operations]下,因此必须对范围进行排序 从字面上

  • c – map,lambda,remove_if2019-09-29 00:17:03

    所以,我对std :: map,lambda和stl算法(remove_if)有疑问.实际上,与std :: list或std :: vector相同的代码运行良好. 我的测试示例: #include <map> #include <iostream> #include <algorithm> struct Foo { Foo() : _id(0) {} Foo(int id) : _id(id) { } in

  • 如何在C中找到两个std :: set的交集?2019-09-28 08:04:33

    我一直试图在C中找到两个std :: set之间的交集,但我一直收到错误. 我为此创建了一个小样本测试 #include <iostream> #include <vector> #include <algorithm> #include <set> using namespace std; int main() { set<int> s1; set<int> s2; s1.insert(1); s1.inser

  • c – 范围v3使序列变平2019-08-28 14:06:03

    所以我最近在c上看了这个演讲: https://www.youtube.com/watch?v=mFUXNMfaciE 我对尝试它非常感兴趣.因此,在一些玩具程序之后,我被困在如何正确地将矢量矢量平面化为矢量.根据这里的文档:https://ericniebler.github.io/range-v3/这可以使用range :: view :: for_each.但是我似乎无

  • c – 从结构访问数据时,运算符重载在哪里?2019-08-26 17:08:30

    我在一个结构中有一个函数,用于对结构中的向量进行排序.但是为了比较向量中的两个元素,我需要在同一个结构中的另一个变量的值.我想知道我应该在哪里保持运算符重载或比较函数这种工作.我在下面的粘贴中给出了一个样本. #include<vector> #include<algorithm> struct Square{

  • c – std :: remove_if是否保证按顺序调用谓词?2019-08-24 02:05:08

    std :: remove_if是否总是按顺序调用每个元素的谓词(根据迭代器的顺序),还是可以不按顺序调用? 这是我想做的玩具示例: void processVector(std::vector<int> values) { values.erase(std::remove_if(values.begin(), values.end(), [](int v) { if (v % 2 == 0)

  • c – 从类成员生成容器2019-08-23 14:08:41

    我想知道std库中是否有一个算法能够将包含类类型的容器转换为另一个容纳该类类型成员的容器. 所以我基本上寻找的是一个STL替代函数,如下面的代码中的copy_acces: template<class InputIterator, class OutputIterator, class Accessor> OutputIterator copy_acces(InputIterator f

  • c – VS 2010编译器错误“c2678没有运算符发现转换const std :: string”,但没有任何东西被声明为const2019-07-25 08:09:05

    我的源代码非常简单: #include <set> #include <string> #include <functional> #include <algorithm> #include <iterator> using namespace std; void test() { set<string> *S = new set<string>; S->insert("hi"

  • c – std :: generate不能在std :: vector上工作2019-07-23 03:06:17

    #include <iostream> #include <random> #include <algorithm> int main() { std::mt19937 mt; std::uniform_int_distribution<int> d(0, 255); int l = 500; std::vector<int> k(l); std::generate(k.begin(), k.end(), d(mt));

  • c – 为什么fill_n()不能用于vector.reserve()?2019-07-22 14:08:53

    我最近正在学习标准库算法,并对函数fill_n(iter, n, val)有疑问.这个函数要求容器至少有n个元素从iter开始. 这是测试代码: // Version 1, Error vector<int> vec; vec.reserve(10); // Only allocate space for at least 10 elements fill_n(vec.begin(), 10, 0); // Version 2,

  • c – lower_bound()算法/ STL使用前置条件2019-06-22 09:38:48

    如果为32位Linux系统编译,下面的代码会返回错误的结果,并且在给定足够大的向量的情况下,同样的问题也适用于64位系统. 通常是否违反了lower_bound或STL的前提条件,如果是,那么在哪里? STL消息来源告诉我,向量的大小被转换为有符号类型,这解释了行为. // compile with and without -

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有