stdmap

    1熱度

    1回答

    std::map<std::string, Obj> myMap; std::set<std::string> mySet; 我想從myMap除去那些對哪些鍵沒有mySet。 我該怎麼做?我找到std::remove_if算法,但是這裏似乎不適用。

    2熱度

    3回答

    #include <map> using namespace std; class C { public: C(map<int,int> m) { } int operator()(int a, int b) { return a < b; } }; int main() { map<int, int> m; map<i

    4熱度

    4回答

    我可以訪問(不鎖定)一個std :: map條目,而另一個線程插入/擦除entrys? 例如僞C++: typedef struct { int value; int stuff; }some_type_t; std::map<char,some_type_t*> my_map; //thread 1 does: my_map.at('a')->value = 1;

    -1熱度

    1回答

    首先,我有以下代碼: map<char*, char*> records; // id, value are buffer variables to store the text that returns from `strcpy()` char *id = (char*)malloc(sizeof(char*) * 20); char *value = (char*)malloc(siz

    3熱度

    4回答

    我有一個很大的圖像數據集,在特定的時間拍攝,其中每個圖像捕獲start_time和stop_time已知並編碼爲雙打。 我想根據模擬時間將每個連續的圖像加載到我的模擬中,即 - 檢查當前模擬時間是否落入開始/停止時間間隔內。 我想爲此使用地圖,其中關鍵是std::pair<double, double>開始&停止時間,值是圖像的完整路徑。 std::map<std::pair<double, do

    1熱度

    2回答

    基於std :: map構建容器時遇到意外的行爲:檢索非現有密鑰的值不提供用默認構造函數構造的新對象。 缺少什麼我在這裏? 減小的測試用例程序: #include <cstdio> #include <algorithm> #include <map> #include <string> static std::string to_lower(const std::string& st

    1熱度

    2回答

    我正在設計一個自定義的ErrorInfo類,可以由其他模塊實現它們來實現其特定的錯誤信息類。錯誤保存在自定義映射中,其中鍵是由實現基類的模塊定義的自定義鍵。關鍵是基類的模板參數。 這裏是示例基類和派生類。 #include <iostream> #include <vector> #include <string> #include <map> using namespace std;

    0熱度

    2回答

    Implementing class for disjoint sets struct Set { int parent,rank; Set(int i):parent(i),rank(0){} Set(const Set& s2):parent(s2.parent),rank(s2.rank){} }; struct Disjoint { st

    3熱度

    3回答

    如何使用string鍵創建std::map鍵和自定義值字段。 我下面想std::map: "Name" "abcd" "age" "50" "Address" "Street" "xxxx" "PIN" "xxxx" "District" "xxxx" "Gender" "Male" 所以我所有的我,除了第三個領域是string,string類型。但該地址本身

    0熱度

    1回答

    我不得不每次都重新創建一個映射,而不是僅僅引用已創建的映射。 這工作: void render(Scene *scene) { map<std::string, Node*> _map = scene->getNodes(); // I don't want recreate the map every time. It is slowing down the render funct