Boost logo

Boost Users :

Subject: Re: [Boost-users] [intrusive] insert_check and insert_commit
From: Ion Gaztañaga (igaztanaga_at_[hidden])
Date: 2011-02-08 16:53:48


El 08/02/2011 0:26, Paul Rose escribió:
> Hi,
>
> I have a question regarding insert_check and insert_commit on an
> intrusive set.
>
> I know that you must call insert_commit after calling insert_check, with
> no modifications to the set between the two calls.
>
> Is it OK, however, to call insert_check and then never call
> insert_commit (even though insert_check was successful)?

Yes, insert_check does not modify the container (except for splay trees).

> Say I have objects contained in multiple sets (using multiple hooks). I
> want to insert a new object into each of the sets, but only if I know
> that the insert will succeed on all of the sets. I call insert_check
> on each, and if all succeed I call insert_commit on each. If any of the
> insert_check calls fail, I do none of the insert_commits (even though
> all but one might have worked)

This seems pretty reasonable.

> It seems like it should be OK, and the documentation doesn't say that it
> won't work. I'm only concerned for two related reasons:
>
> 1) insert_check is not declared const. Does this mean that the set is
> already partially modified?

I think it should be declared const for all (multi)set types except for
splay trees (because in this case a search rebalances the tree),

> 2) insert_commit is documented as constant time. Does this mean that
> any red-black rebalancing was already done during insert_check? If so,
> what happens if I never do the insert_commit?

Insert check rebalances the three if needed. This is amortized
constant-time so I should change this complexity in the documentation.

Best,

Ion


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net