CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5
  1. #1
    Join Date
    Jul 2002
    Posts
    372

    stl set question

    hi,

    CString buff( "abc" );
    std::set< CString > s;
    s.insert( buff );
    s.insert( buff );
    s.insert( buff );
    s.insert( buff );
    s.insert( buff );
    s.insert( buff );

    does the set inserts "abc" once ?

    thanks

  2. #2
    Join Date
    Aug 2000
    Location
    West Virginia
    Posts
    7,725

    Re: stl set question

    Yes. Just examine s.size()

    If you want it inserted more than once, use multiset instead of set

  3. #3
    Join Date
    Jul 2002
    Posts
    372

    Re: stl set question

    thanks Philip.
    let me extend the question, when i insert n items to the set,
    and than iterate on the set, do i get the items at the same
    order they were inserted ?

  4. #4
    Join Date
    Aug 2000
    Location
    West Virginia
    Posts
    7,725

    Re: stl set question

    No. set orders the items. By default, it uses operator <
    but you can provide the constructor with a predicate also.

  5. #5
    Join Date
    Jul 2002
    Posts
    372

    Re: stl set question

    thanks again

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured