CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Mar 2005
    Posts
    30

    Do I need to re-sort the set?

    Hi all,

    I have a multiset<CMyStruct*, CMyStructLess>. When I insert pointers into the set, the sequence is ordered as expected.
    Now I need to change the items that the multiset pointers point to and the the sequence should be changed after my code changes the items. Does multiset sorts the set automatically?

    Thanks.
    Haoshi

  2. #2
    Join Date
    May 2004
    Location
    Norway
    Posts
    655

    Re: Do I need to re-sort the set?

    Nope. Not when you change the value the pointer points to. You'd have to remove the pointer, change the value, and then insert it again. Otherwise the set won't know the value changed.
    Insert entertaining phrase here

  3. #3
    Join Date
    Mar 2005
    Posts
    30

    Re: Do I need to re-sort the set?

    Thanks. what about the performance if I call erease() and insert().
    Last edited by haoshi; March 17th, 2005 at 02:17 PM.

  4. #4
    Join Date
    Jun 2003
    Location
    Armenia, Yerevan
    Posts
    720

    Re: Do I need to re-sort the set?

    I guess both take O(log(n)).

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