I’m having a hard time conceptualizing c++ sets, actually sets in general.
What are they? How are they useful?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Don’t feel bad if you have trouble understanding sets in general. Most of a degree in mathematics is spent coming to terms with set theory:
http://en.wikipedia.org/wiki/Set_theory
Think of a set as a collection of unique, unordered objects. In many ways it looks like a list:
{ 1, 2, 3, 4 }
but order is unimportant:
{ 4, 3, 2, 1} = { 1, 2, 3, 4}
and repetitions are ignored:
{ 1, 1, 2, 3, 4 } = { 1, 2, 3, 4}
A C++ set is an implementation of this mathematical object, with the odd feature that is is sorted internally. But this is just a detail of implementation, and is not relevant to understanding the data structure. The sorting is just for speed.