In C++, `std::set`s are a kind of associative container that stores unique elements, and in which the elements themselves are the keys.
Questions tagged [stdset]
294 questions
0
votes
1 answer
inserting on a pointer to std::set
Inserting values on Set with and without pointer behaves differently.
What is wrong with this code?
The first for loop is insertion on set using pointer and the second is without pointer.
But apart from that everything else is exactly…

mvairavan
- 129
- 1
- 11
0
votes
1 answer
Get values in a struct stored in C++ set
I declare a struct called Position with 2 data members: x, y. I want to store instances of these structs into a std::set. How can I later retrieve the value of x, y from the right Position struct?
struct Position
{
long m_x;
long m_y;
…

user2345939
- 65
- 3
0
votes
1 answer
copying elements from std::vector to std::set based on condition but it crashes
class Information
{
public:
const std::string comp_num() const;
const std::string comp_address() const;
void set_comp_address( const std::string& comp_address );
void set_comp_num( const std::string& comp_num );
private:
…

samprat
- 2,150
- 8
- 39
- 73
0
votes
1 answer
Using std::set or std::map with shared memory
I am working in a project which have two different processes.
The first process is a cache base on a std::map or std::set which allocate all the data in a share memory region.
The second process is a producer/consumer which will have access to…

Vicente Bolea
- 1,409
- 16
- 39
0
votes
0 answers
Linker Error with std::multiset insert operation
I have copied header file and cpp file from one of my old project( build in VS-2010) into new project( developing it in QT5.1) and have encounter this weird error
1>Message_list.obj : error LNK2019: unresolved external symbol "public: bool…

samprat
- 2,150
- 8
- 39
- 73
0
votes
2 answers
Ordering output of C++ std::set
I want to list the output of my set in alphabetical order. Below is an attempt at getting to this, but it seems slow / inefficient and I haven't even finished it yet.
void ordered(ostream &os) {
bool inserted = false;
for (objects::iterator…

dudledok
- 2,800
- 5
- 24
- 36
0
votes
1 answer
Is there a limit on the size of std::set::iterator?
I have a std::set of strings and I want to iterate over them, but the iterator is behaving differently for different sizes of set. Given below is the code snippet that I'm working on:
int test(set &KeywordsDictionary){
int keyword_len =…

annunarcist
- 1,637
- 3
- 20
- 42
0
votes
1 answer
Detecting cyclic pairs
Assume a std::set< std::pair >, can somebody suggest an algorithm or approach to check whether there are cyclic pairs?
e.g.
std::set< std::pair > cyclic = { {'A', 'B'}, {'B', 'C'}, {'C', 'A'} };
std::set< std::pair

user2804578
- 32
- 1
- 4
0
votes
1 answer
C++ how does std::set handle dynamic ordering of elements
I have a set declared with my own comp function:
set my_set;
The comparison function uses some data stored elsewhere to decide which int is greater.
If said data changes, the order of the elements of the set changes too.
How does set…

user2460978
- 735
- 6
- 19
0
votes
0 answers
C# data structure that supports find next, find previous, is a sorted list, can be iterated through
Is there a C# data structure that does the followings :
Find max,min in O(1).
Delete and insert in O(logN);
FindNext(int var) : the smallest element that is larger than var in O(logN);
FindPrevious(int) : reverse of FindNext(int)
Can be iterated…

David Mahone
- 245
- 1
- 7
0
votes
3 answers
How to loop over elements in a std::set/ add condition to std::for_each over a std::set in vs2008?
from here :
http://www.boost.org/doc/libs/1_53_0/doc/html/boost_asio/example/chat/chat_server.cpp
std::set participants_;
....
participants_.insert(participant);
....
void deliver(const chat_message& msg,…
user494461
0
votes
4 answers
C++ std::set custom comparator
Well, my problem is that I'm using an std::set with a custom comparator, something like:
class A
{
public:
A(int x, int y):
_x(x), _y(y)
{
}
int hashCode(){ return (_y << 16) | _x; }
private:
short int _y;
short int…
user1320847
0
votes
4 answers
Access Violation Reading Location on std::set::erase
I have recently caught the following crash in my application:
m_players[0].erase(plr); -- CRASHES HERE
m_players[1].erase(plr);
m_players is declared as:
set m_players[2];
Visual Studio shows that it is "0xC0000005: Access…

Guest
- 111
- 1
- 5
0
votes
1 answer
C++ instantiated from here error with std::set
I found a bunch of threads about the "instantiated from here" problem. They all seemed to be people who created forgot a default constructor. I think my problem is different (however I am new to C++ and it could be a slight variation on the same…

Chase Roberts
- 9,082
- 13
- 73
- 131