Boost logo

Boost :

From: Daryle Walker (darylew_at_[hidden])
Date: 2007-07-17 16:24:39


I was thinking of using a multi-indexed container as part of an
implementation of another container. The final container will have an
interface like a set, but internally the elements sometimes have to be
accessible via random-access iteration[1]. Implementing with a straight
set would limit me to bidirectional iteration, which will slow down
internal operations that need random access.

The internal multi-index container would have set and vector aspects,
i.e. ordered-unique and random-access index specifiers. Even though the
external interface will be like a set, should I have publicize the
vector-like operations "capacity" and "reserve"? Will reserving
capacity help in the ordered-unique part of any insertions?

Alternatively, is there a better way to implement a set w/ random-access
iteration besides this multi-index idea?

[1] I think that the external iterators should stay bidirectional. That
way I can transfer the ordered-unique view's iterators and give a
consistent traversal order. If I use the random-access view's
iterators, I could traverse better but there'll be no obvious rule to
the arrangement of elements from the user's perspective.

-- 
Daryle Walker
Mac, Internet, and Video Game Junkie
darylew AT hotmail DOT com

Boost list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk