Skip to main content
5 votes
1 answer
122 views

I asked the similar question for find() method of std::unordered_set last day - How can I use a lightweight argument in unordered_set::find() method?. But the recommendations received for find() ...
mistermad's user avatar
4 votes
1 answer
105 views

Must I fully build a Storage object for finding it, instead of using std::string because of having operator== for it? #include <cstddef> #include <functional> #include <string> #...
mistermad's user avatar
2 votes
1 answer
166 views

I am trying to solve this question in O(N^3) time complexity but unable to get the right answer in C++. The question states: Design a function that takes in >=4 points and returns the number of ...
Ridwan Chowdhury's user avatar
2 votes
1 answer
115 views

I have a custom data type Position that i use in std::unordered_set #include <unordered_set> struct Position { int y; int x; bool operator==(const Position& other) const { ...
Awed2's user avatar
  • 71
3 votes
1 answer
613 views

Code pasted below: auto myComp = []( std::array<const string, 3> &a, std::array<const string, 3> &b ) { if ( a[0] == b[0] && a[1] == b[1] && a[2] == b[2] ) { ...
PkDrew's user avatar
  • 2,301
12 votes
1 answer
605 views

I'm using std::unordered_set for the first time with a custom type, and I can't figure out what I'm missing to make contains() compile for my set. I basically have a class which looks something like ...
Dzious's user avatar
  • 401
-2 votes
1 answer
105 views

std::unordered_set<Vector2i> basicWalls = FindWalls(floorPositions, cardinal2D); std::unordered_set<Vector2i> cornerWalls = FindWalls(floorPositions, Diagonal2D); printf("basic ...
Baris S's user avatar
1 vote
1 answer
76 views

I am using boost's managed_shared_memory, below is the A program which is responsible for creating and constructing an unordered_set. #include "pch.h" #include <iostream> #include <...
user25203529's user avatar
-1 votes
1 answer
85 views

AFAIU (maybe I am wrong), unordered_set/unordered_map use underlying array or vector for buckets, and in each bucket there is a list of keys (or key-value). So when we want more buckets, larger array ...
Andrey Rubliov's user avatar
0 votes
1 answer
36 views

I have a struct MyStruct which I have an unordered_set for which has it's own hashing function MyStructHash so that I can define unordered_set<MyStruct, MyStructHash> struct_set;. MyStruct is ...
B.K Lewis's user avatar
0 votes
2 answers
196 views

I am trying to understand how STL unordered set/map (i.e. hash maps) work. I understood that initial hash table size (i.e. number of buckets) is set to 8 and when more elements are added to the set/...
Andrey Rubliov's user avatar
0 votes
2 answers
336 views

For figuring out the best container type for my specific purpose, I was comparing lookup times of std::vector, sorted std::vector with binary search, std::set and std::unordered_set. Here are the ...
mqnc's user avatar
  • 766
0 votes
2 answers
492 views

I know that unordered_set might invalidate iterators when elements are inserted: "If rehashing occurs (due to the insertion), all iterators are invalidated." It is clear, because we have ...
QuickDzen's user avatar
  • 281
0 votes
1 answer
191 views

As far as I'm aware, resizing an array (like push_back on a vector that requires resizing the array) is O(n) complexity. If this is the case, does this hold for insert in unordered_set? Does resizing ...
LittleSilver's user avatar
2 votes
1 answer
489 views

I have seen some similar questions, like this, this and this, however they all are quite old and might be obsolete. It is 2023 and the latest C++ standard is C++20 which was published in 2020, and ...
Ξένη Γήινος's user avatar

15 30 50 per page
1
2 3 4 5
31