C + +: About Set

Source: Internet
Author: User

1. Initialization of the Set

The set can be initialized like this:

set<int1,2,3  };   set<int1,2,3 };  

When the set is initialized, duplicate elements appear:

set<int1,2,3,3,3  };   set<int1,2,3,3,3 };  

The extra repeating element is deleted when it is stored, and if printed, the set has only three elements.

2. About Set iterators

Because set does not define a + and-operation, there is no way to specify iterators in a set.iterator+n way, such as this

Set<int> an_set1{2,3,4,5,6};

Vector<int> An_vector2 (An_set1.begin () +1, An_set1.end ());

Such an operation is wrong. However, set defines the iterator's self-plus + + and auto-subtract + +, so it is possible to iterate over the set element with an iterator.

C + +: About Set

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.