unordered-map Questions
3
Solved
I'm using external networking library which returns some magic structures representing opened sockets and the docs say that when inserting them into STL containers, they should be compared using st...
Floodgate asked 13/7, 2015 at 7:58
1
I know about this question, but mine is a bit different.
Why does rehash have quadratic complexity, but operator [] (which can call rehash) has linear complexity in worst case?
Sorry, but I don't h...
Hep asked 9/2, 2024 at 18:40
4
Solved
What is the fastest way to figure out if an unordered_map container has an item with a specified key?
Carhart asked 4/1, 2013 at 15:9
8
I am trying to use a custom class as key for an unordered_map, like the following:
#include <iostream>
#include <algorithm>
#include <unordered_map>
using namespace std;
class ...
Maniemanifest asked 10/6, 2013 at 2:34
2
I'm using unordered_map as a hashmap in C++, but whenever I try to store anything in there, I get:
Floating point exception: 8
Can anyone point out what the error is? The following is how I initi...
Nabalas asked 24/10, 2013 at 3:47
3
Solved
I want to remove elements (histogram bins) from an std::unordered_map (histogram) that fulfills a predictate (histogram bins having zero count) given as a lambda expression as follows
std::remove_...
Comrade asked 9/2, 2012 at 11:25
4
Solved
I want to declare :
std::unordered_map<CString, CString> m_mapMyMap;
But when I build I got an error telling me that the standard C++ doesn't provide a hash function for CString, while CSt...
Shred asked 15/2, 2016 at 11:37
1
I found both container used in our codes. This is a bit of confusing, especially when I include libs that depends on both of them.
So what is the main difference between these two implementations?...
Idoux asked 12/10, 2015 at 3:23
4
Solved
I need to use a data structure which supports constant time lookups on average. I think that using a std::unordered_map is a good way to do it. My data is a "collection" of numbers.
|115|190|380|2...
Morton asked 25/9, 2018 at 5:25
3
Solved
I am solving a problem on LeetCode, but nobody has yet been able to explain my issue.
The problem is as such:
Given an arbitrary ransom note string and another string containing letters from all th...
Haemo asked 1/4, 2019 at 9:24
5
Solved
Why doesn't std::unordered_map<tuple<int, int>, string> just
work out of the box?
It is tedious to have to define a hash function for tuple<int, int>, e.g.
template<> str...
Saltworks asked 18/8, 2011 at 15:49
2
Solved
In §23.2.7 Unordered associative containers [unord.req] of the C++ standard table 91 describes the additional requirements a STL unordered associative container must meet. In this table the standar...
Swinton asked 14/2, 2017 at 12:54
3
Solved
We know that hash table based container implementations like std::unordered_map use a lot memory but I don't know how much is how much?
Apart from space complexity notations, and not considering i...
Fougere asked 19/8, 2014 at 3:17
6
Solved
What is the most efficient way of obtaining lists (as a vector) of the keys and values from an unordered_map?
For concreteness, suppose the map in question is a unordered_map<string, double>...
Creative asked 13/12, 2011 at 3:28
2
Solved
Can somebody explain why insertion into std::unordered_map container only invalidates iterators but not references and pointers. Also I am not able to understand what the below statement from https...
Cerate asked 16/5, 2022 at 7:34
9
Solved
I am trying to create an unordered_map to map pairs with integers:
#include <unordered_map>
using namespace std;
using Vote = pair<string, string>;
using Unordered_map = unordered_map...
Ivie asked 20/9, 2015 at 23:56
1
When trying to access a member of std::unordered_map using [], I get an error:
Attempt to take address of value not located in memory.
There is a nice gdb-stl-views, except it does not support...
Zymogenesis asked 31/8, 2015 at 8:1
3
I'm trying to create a hash of arrays of pointers to my object.
The hash key is an int for the type of the object, and the array is a list of the objects to render.
What I'm trying to do is :
unord...
Basilicata asked 18/6, 2012 at 10:51
3
Solved
I have a class C, which has a string* ps private data member.
Now, I'd like to have an unordered_map<C, int> for which I need a custom hash function.
According to the c++ reference, I can do...
Greaser asked 15/12, 2012 at 8:49
2
I have C++ code that investigates a BIG string and matches lots of substrings. As much as possible, I avoid constructing std::strings, by encoding substrings like this:
char* buffer, size_t buffer...
Jesus asked 7/4, 2018 at 16:32
1
From iterator invalidation rules described at stackoverflow and cppreference, I know that iterator is not invalidated for unordered_map unless rehashing is occurring.
If I use std::vector analogy,...
Homeomorphism asked 18/10, 2018 at 18:2
8
Solved
I want to use tuple consisting of int,char,char in my unordered_map. I am doing like this:
#include <string>
#include <unordered_map>
#include <cstring>
#include <iostream>...
Oloroso asked 30/12, 2013 at 7:0
15
Solved
A recent talk about unordered_map in C++ made me realize that I should use unordered_map for most cases where I used map before, because of the efficiency of lookup ( amortized O(1) vs. O(log n) )....
Barouche asked 4/2, 2010 at 2:37
7
Solved
I am using an unordered_map of unordered_maps, such that I can reference an element using the "multi key" syntax:
my_map[k1][k2].
Is there a convenient way to use the same "multi-key" syntax to ...
Rat asked 29/12, 2015 at 13:49
3
Solved
Looking around on cppreference, I found that std::unordered_map gets efficient lookup functions from "equivalent keys".
I take that to mean that the equivalent key must have the same hash value. H...
Armistice asked 3/12, 2013 at 12:9
1 Next >
© 2022 - 2025 — McMap. All rights reserved.