-1

I want to add sets {1,3,5} and set {2,8} into a "list". How or which data structure should I use?

I basically want it to be able to store groups. I tried vector of vectors, or I need set with multiple key values in C++.

sets = {{1, 2, 3}, {2, 3}, {3, 5}};
Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Pavan Kate
  • 84
  • 1
  • 8

1 Answers1

0

The standard library has a set data structure already.

A vector of sets would be the simplest approach:

std::vector<std::set<int> >
jalf
  • 243,077
  • 51
  • 345
  • 550
  • vector of sets would store 1,2 ,3 in one set and this is at one l;ocation element of vector s it? – Pavan Kate Apr 09 '15 at 09:29
  • I'm not sure what you mean. A vector of set would store three sets: the first containing `{1,2,3}`, the second containing `{2,3}` and the third containing `{3,5}`. Isn't that what you want? – jalf Apr 09 '15 at 09:33