Boost logo

Boost :

From: Brey, Edward D (EdwardDBrey_at_[hidden])
Date: 2002-01-08 18:22:39

> {Dave}
> There should be an insert interface which inserts in-order.
> There should also be one that inserts "with hint" at the closest
> position to the supplied iterator.
> {Ed}
> If I understand you correctly, you're saying that there should be
> validated and non-validated insertion, where the non-validated
> a postcondition of an ordered (and hence acceptable for lookup)
> the position argument be the correct insertion spot in a
> container.

        Nope, I want to say instead that lookup has a precondition that the
        container is sorted. IOW, I want to be able to say:

        assoc_vec<int> x(make_counting_iterator(0),
        x.insert(make_counting_iterator(75), make_counting_iterator(100));
            , make_reverse_iterator(make_counting_iterator(70))
            , make_reverse_iterator(make_counting_iterator(30))); // legal!

        x.lower_bound(42); // illegal

        sort(x.begin(), x.end());
        x.lower_bound(42); // legal

OK. It sounds like the we are saying the same thing in slightly different
words. I agree that lower_bound needs the precondition that the container
is sorted? So when is the container sorted? When unsafe_insert's
postcondition says that it is sorted. When is that? When unsafe_insert's
position parameter happens to be the right location.

Your example makes the second lookup work by doing a sort. My example makes
it work by inserting into the right location in the first place so that the
container is never unsorted in the first place. Both methods should be

        My proposal was the original resolution to,
though we
        "chickened out" and opted not to invent new functionality at the

My reading of this indicates that the plan is to continue to _not_ give the
programmer control over the insertion location. This is too bad, since that
would comes in handy on occasion. It would be nice if the vector
associative containers provided the programmer control over precise
insertion location.

Boost list run by bdawes at, gregod at, cpdaniel at, john at