[multi_index] key swap status

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

[multi_index] key swap status

gruenedd
Hello,

What is the status of key swapping, issued here[1]?
Do you see a chance to have this included sometime? :]

Best Regards,
David

[1] http://lists.boost.org/boost-users/2005/04/11223.php

----------------------------------------------------------------
This message was sent using IMP, the Internet Messaging Program.
_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
Reply | Threaded
Open this post in threaded view
|

Re: [multi_index] key swap status

Joaquin M LópezMuñoz
Hello David,

[hidden email] ha escrito:

> Hello,
>
> What is the status of key swapping, issued here[1]?
> Do you see a chance to have this included sometime? :]

Nothing like that has been included in Boost 1.34, and I decided
to finally not implement the idea because:

* It can be simulated externally (admittedly, not in an optimal
fashion).
* I don't see as a commonly wanted feature.
* It implies weird semantics: swapping keys can result
in collisions arising in other indices. Consider for instance:

multi_index_container<
  std::pair<int,int>,
  indexed_by<
    ordered_unique<member<std::pair<int,int>,int,&std::pair<int,int>::first> >,
    ordered_unique<identity<std::pair<int,int> > >
  >
> c;

c.insert(std::make_pair(0,1));
c.insert(std::make_pair(1,0));
c.insert(std::make_pair(1,1));
c.swap_keys(c.begin(),++c.begin()); // would yield a duplicate element (1,1)

Not that this cannot be handled, but it implies that a possible outcome
of swap_keys() is that both elements get deleted or the operation
rolled back, which is IMHO a little surprising to the unadvertent user.

I'm sorry the answer to your proposal is negative.

> Best Regards,
> David
>
> [1] http://lists.boost.org/boost-users/2005/04/11223.php

On another issue, you might be interested to know that the problem
you brought forward in

http://lists.boost.org/Archives/boost/2005/02/80589.php

has been solved in 1.34, and the very sample snippet you provided
then now compiles and works cleanly. The solution does not follow
your proposed approach, but uses boost::disable_if<> instead.
More info at

http://boost-consulting.com/boost/libs/multi_index/doc/release_notes.html#boost_1_34

(third bullet). Best regards,

Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo

_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
Reply | Threaded
Open this post in threaded view
|

[multi_index] - Thank You

Joseph Wu-2
Hi Joaquin,

I just would like to send a personal note to say thank you for the wonderful
job on multi-index. I have used it since the early days, and found it rather
useful. Having just read the 1.34 release notes, the addition of
random-access index and other constant improvements are really encouraging.

Thanks again,

Joseph


_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
Reply | Threaded
Open this post in threaded view
|

Re: [multi_index] - Thank You

Joaquin M LópezMuñoz
----- Mensaje original -----
De: Joseph Wu <[hidden email]>
Fecha: Viernes, Febrero 24, 2006 5:34 pm
Asunto: [boost]  [multi_index] - Thank You

> Hi Joaquin,
>
> I just would like to send a personal note to say thank you for the
> wonderfuljob on multi-index. I have used it since the early days,
> and found it rather
> useful. Having just read the 1.34 release notes, the addition of
> random-access index and other constant improvements are really
> encouraging.
> Thanks again,
>
> Joseph

Hello Joseph, thank you very much for your compliments, it's
a rewarding feeling to know the lib is appreciated and used
out there.
Some proposals of new features have had low response in the
past, which made me wonder whether the features were worth
including after all. So I'm always eager to receive as much
feedback as possible on how to make Boost.MultiIndex better
suited to its users' needs.

Best regards,

Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo

_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
Reply | Threaded
Open this post in threaded view
|

Re: [multi_index] key swap status

gruenedd
In reply to this post by gruenedd
Joaquín Mª López Muñoz wrote:
> c.insert(std::make_pair(0,1));
> c.insert(std::make_pair(1,0));
> c.insert(std::make_pair(1,1));
> c.swap_keys(c.begin(),++c.begin()); // would yield a duplicate element (1,1)

> ... it implies that a possible outcome
> of swap_keys() is that both elements get deleted

That`s  what i would expect here. :]
Now, why is this surprising? Consider the following snippet:

multi_index_container<int> c; // default "set"-like
c.insert(1);
c.insert(2);
c.modify_key(--c.end(), _1 = 1);

Isn`t it "surprising" in the same way, that c.size() == 1? ;-)

> On another issue, you might be interested to know that the problem
> you brought forward in
>
> http://lists.boost.org/Archives/boost/2005/02/80589.php
>
> has been solved in 1.34

Nice!

Best Regards,
David.

----------------------------------------------------------------
This message was sent using IMP, the Internet Messaging Program.
_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
Reply | Threaded
Open this post in threaded view
|

Re: [multi_index] key swap status

Joaquin M LópezMuñoz


[hidden email] ha escrito:

> Joaquín Mª López Muñoz wrote:
> > c.insert(std::make_pair(0,1));
> > c.insert(std::make_pair(1,0));
> > c.insert(std::make_pair(1,1));
> > c.swap_keys(c.begin(),++c.begin()); // would yield a duplicate element (1,1)
>
> > ... it implies that a possible outcome
> > of swap_keys() is that both elements get deleted
>
> That`s  what i would expect here. :]
> Now, why is this surprising? Consider the following snippet:
>
> multi_index_container<int> c; // default "set"-like
> c.insert(1);
> c.insert(2);
> c.modify_key(--c.end(), _1 = 1);
>
> Isn`t it "surprising" in the same way, that c.size() == 1? ;-)

Yep, well. I don't know, swap_keys's very name seems to indicate
it'll follow std::swap semantics, which certainly doesn't have
elimination of swapped elements as a possibility.
Anyway, the other two reasons I gave for not providing this
feature have more weight in my decision.

Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo

_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
Reply | Threaded
Open this post in threaded view
|

Re: [multi_index] key swap status

gruenedd
Quoting Joaquín Mª López Muñoz <[hidden email]>:

> Anyway, the other two reasons I gave for not providing this
> feature have more weight in my decision.

And they are valid. :]
Nevertheless, as Joseph stated, multi_index is really useful.

David.

----------------------------------------------------------------
This message was sent using IMP, the Internet Messaging Program.
_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost