unordered-set Questions
4
Solved
I know hash_set is non-standard and unordered_set is standard. However, I am wondering, performance wise, what is the difference between the two? Why do they exist separately?
Milburn asked 1/10, 2011 at 22:19
3
Solved
I'll start by illustrating a simple use case example:
Consider the problem of a social security ID database, where in C++ code is modelled as a std::unordered_map where its key is the social secu...
Checkerboard asked 13/6, 2014 at 19:9
2
Solved
Both std::set<> and std::map<> can use a std::pair as a key, but why can't std::unordered_set<> and std::unordered_map<>?
For example:
unordered_set<pair<int,i...
Truce asked 24/5, 2015 at 3:6
4
Solved
I'm curious as to why the STL container unordered_set, which has constant time complexity for random access on average, does not provide a method for accessing elements by some distance from the fi...
Dowery asked 10/4, 2015 at 1:56
3
Solved
Does C++ have an equivalent to python's set.pop()? I've been looking at the documentation for unordered_sets here, but there doesn't seem to be a way to 1. Access an arbitrary element, and/or 2. Ac...
Donne asked 22/9, 2014 at 0:10
1
Solved
There are plenty of answers with std::vector, but what about std::unordered_set?
My real question (closely related) is this; is it efficient to reuse the same unordered set by clearing it before e...
Gracia asked 4/9, 2014 at 23:46
4
Solved
How can I make unordered_set with lambda? (I know how to make it with user defined hash struct and operator==)
My current code is :
#include <unordered_set>
#include <functional>
st...
Babbitt asked 22/8, 2014 at 20:4
1
If I insert the same (size and value) elements in two unordered containers, will traversing the containers with two iterators always give the same element in the same position?
If yes, can a (sing...
Truscott asked 28/7, 2014 at 8:38
5
In my application I have the following requirements -
The data structure will be populated just once with some values (not key/value pairs).
The values may be repeated but I want the data structu...
Cedar asked 1/7, 2014 at 9:27
2
Solved
I have a class (call it Outer) which has a private member class (Inner). I want to store instances of Outer::Inner in unordered standard containers, so I want to specialize std::hash<Outer::Inne...
Hertel asked 20/4, 2014 at 21:11
1
Solved
I have a list of items that are created each frame and need to be sorted.
Each Item's first member variable to sort by is an unordered_set.
I've moved this to an ordered set everywhere in the syst...
Breeze asked 10/2, 2014 at 15:54
1
Solved
I need to create a templated class that can hold pointers to elements of type T and then performs functions on them. The functions will come from different places, so I need a container to store th...
Brodsky asked 19/12, 2013 at 22:17
2
I wanted to have something like
unordered_set<vector<pair<int,int>>> us;
but even without pair:
#include <vector>
#include <unordered_set>
using namespace std;
...
Baldridge asked 29/10, 2013 at 10:34
1
Solved
Like the question says, can you remove an element from a std::unordered_set using a bucket iterator (local_iterator)? I can see two possible solutions:
Since erase() does only accept global itera...
Sabu asked 29/8, 2013 at 7:34
1
Solved
I do not understand why hastable's rehash complexity may be quadratic in worst case at :
http://www.cplusplus.com/reference/unordered_set/unordered_multiset/reserve/
Any help would be appreciated...
Matutinal asked 10/8, 2013 at 18:1
1
Solved
I am trying to define an unordered_set like this:
unordered_set<Point> m_Points;
When I compile it, I get the following error:
The C++ Standard doesn't provide a hash for this typ...
Alwyn asked 7/8, 2013 at 8:17
1
Solved
I'am trying to use std::unordered_set in cross-platform C++ application. It compiles and works like a charm in Visual C++ under Windows, but generates a fatal compilation error on clang under Mac O...
Alluvial asked 26/7, 2013 at 15:39
1
Solved
So the library I use has an enum (say it's named LibEnum). I need to have an std::unordered_set of LibEnum, but I get compilation error that there is no specialized std::hash for it. I could easily...
Seedcase asked 11/2, 2013 at 14:23
4
Solved
I'm storing pointers in std::unordered_set. I do this because I don't want any duplicates (I delete the pointers in the collection, so if there is a duplicate, I will attempt to delete an already d...
Nasturtium asked 17/1, 2013 at 17:25
4
Solved
I'd like to use unordered_set in a project.
However, documentation for it is either incomplete or just a technical reference, no examples.
Can anyone provide links to online resources which deal...
Valletta asked 12/12, 2010 at 17:23
2
Solved
Is there an easy way to add all the elements of a vector to an unordered_set? They are of the same type. Right now, I am using a for loop and was wondering if there is a better way to do it
Little asked 12/10, 2012 at 1:17
2
Solved
Apparently, unordered_set::erase and unordered_set::count return something that is not strictly boolean (logically, that is, I'm not talking about the actual type).
The linked page reads for the t...
Plywood asked 8/8, 2012 at 7:0
1
I have to use unordered_set for a rather large project, and to make sure I was using it correctly I tried a small example.
#include <iostream>
#include <unordered_set>
using name...
Orangewood asked 3/8, 2012 at 20:38
2
Solved
Given two std::sets, one can simply iterate through both sets simultaneously and compare the elements, resulting in linear complexity. This doesn't work for std::unordered_sets, because the element...
Scrapbook asked 12/4, 2012 at 6:33
1
Solved
std::unordered_set<my_type> my_set;
Which requirements must my_type fulfill here? (Besides a specialization for std::hash)
Chaffee asked 29/3, 2012 at 14:17
© 2022 - 2024 — McMap. All rights reserved.