Questions tagged [stdset]

In C++, `std::set`s are a kind of associative container that stores unique elements, and in which the elements themselves are the keys.

294 questions
0
votes
1 answer

What is the defining quality of the indirection operator?

I have code whereby I can query a structure for a std::set of objects of type A that all match some criteria. I will very often want my query criteria to be such that the code returns a set containing only one object. And in these cases, I will want…
DanielGr
  • 191
  • 1
  • 6
0
votes
2 answers

std::set. Custom set of sets

Word. I have a struct, containing a single field that I would like set to use for comparison and equivalence, and other fields as metadata: struct read_tag{ unsigned int read_id; // want std::set to use this int offset; //…
izaak_pyzaak
  • 930
  • 8
  • 23
0
votes
0 answers

what are the containers in C++ STL to store a small number of integer values and find them in O(1)

Suppose, I want to create a vector of vectors to store/find the edges between the nodes in a graph. There are many points in the graph which doesn't have any edge and I don't want to save them. e.g. there are 2 millions nodes which 1.5 million of…
eSadr
  • 395
  • 5
  • 21
0
votes
2 answers

Compile error in standard library when compiling code

I've done quite some java coding already, but I'm totally new to c++ and have no idea what's going on with my code right now. This code gives me a compile error in the map standard library. It says: Cannot increment value of type '…
Fr4nc3sc0NL
  • 555
  • 1
  • 6
  • 22
0
votes
2 answers

Forming the union of two sets seems to give wrong and inconsistent answers

The following code is my attempt to form the union of the two element set {2,3} with the empty set {}. I expect that the resulting container (in this case, a list) should have size 2. However, when I run the code, I get that the size of the union…
sitiposit
  • 149
  • 1
  • 13
0
votes
1 answer

Insert values in a vector of int sets in C++

I want to insert values into a vector of set, which is defined using typedef as given below: typedef std::set blockSet_t; std::vector* myvector I want to have values such that myvector[0] has a set of ints, myvector[1] has a…
0
votes
2 answers

Efficient way to get subset of std::set

I call a library function that accepts pointer to std::set and processes elements of it. However, it processes only certain number of elements (let's say 100) and if the set has more elements it simply throws an exception. However, I receive set of…
Atul
  • 3,778
  • 5
  • 47
  • 87
0
votes
1 answer

OpenMP through std::set using iterator

I have a mesh with huge number of segments, I want to apply filter and fill std::set set_, which is private member of class A. There is function called fill_vec() which is going to fill the vector using a for loop: fill_set() { …
H'H
  • 1,638
  • 1
  • 15
  • 39
0
votes
1 answer

How do I trigger std::set's worst-case insert(), contains(), and remove() operations?

I understand that the std::set is likely some sort of tree. I want to trigger std::set's worst-case insert(), contains(), and remove() operations - which I expect will take O(log(n)) time. I do not want to implement my own tree - I want to use…
user3076399
  • 121
  • 3
  • 13
0
votes
2 answers

how to use std::find with an < operator that is not std::less

say I have class newVector: public std::vector { public: bool operator< (const newVector& v) { //.. } }; And a std::set; I can't manage to use a.find(...) properly, I am not sure what to put into…
myelf
  • 43
  • 5
0
votes
1 answer

How to ensure no duplicates in boost::unordered_set of custom data

I need my container to contain unique elements only, so I have a structure like this: class OD { private: std::string key; public: OD(){} OD(const WayPoint &origin, const WayPoint &destination): origin(origin),…
rahman
  • 4,820
  • 16
  • 52
  • 86
0
votes
1 answer

VectorXd and std::set: duplicate elements

I'm trying to use std::set together with VectorXd from the Eigen library: typedef VectorXd Vec; bool(*fn_pt)(Vec,Vec) = vecCompare; set yx (fn_pt); The function vecCompare ist defined as follows: bool vecCompare(Vec v, Vec w)…
user2442121
0
votes
0 answers

Efficiently processing large number of unique elements (std::set vs other containers)

I have std::set having large number unique objects as its elements. In the main thread of program: I take some objects from the set Assign data to be processed to each of them Remove those objects from set And finally pass the objects to…
Atul
  • 3,778
  • 5
  • 47
  • 87
0
votes
2 answers

Custom comparison operator and custom class for std::set in C++

I would like to create a set containing the objects of my class, I have to determine a custom comparison. Unfortunately, everything I tried did not work. class My_Class { public: char letter; set
Delgan
  • 18,571
  • 11
  • 90
  • 141
0
votes
1 answer

How to use C++ std::sets as building blocks of a class?

I need a data structure that satisfies the following: stores an arbitrary number of elements, where each element is described by 10 numeric metrics allows fast (log n) search of elements by any of the metrics allows fast (log n) insertion of new…