Boost logo

Boost :

From: Joerg Walter (jhr.walter_at_[hidden])
Date: 2004-03-24 02:48:47


Hi Joaquin,

you wrote:

> I forgot to answer one of your questions. Here it comes:
>
> Joerg Walter <jhr.walter <at> t-online.de> writes:
> > One more question: is there an (easy?) way to
> > iterate over the distinct values of an index
>
> You can do it as you would with a std::multiset:
>
> typedef indexed_set<...> indexed_t;
> typedef indexed_t::index_type<...>::type index_t;
>
> indexed_t iset;
> index_t& index=iset.get<...>();
>
> for(index::iterator it=index.begin();it!=index.end()){
> // do what you want to with the value
>
> // get next value
> it2=index.upper_bound(index.key_extractor()(*it));
> it=it2;
> }

Understood, a non_unique key has multi_set characteristics, whereas a unique
key has set characteristics.

> > (or to define the index as the
> > set of distinct values of the related attribute(s))?
>
> This would call for a new type of index, IHMO. Gotta
> think it over.

On a second thought: such a beast would be more of a view (losing the
relation to indexed_set's original data) and therefore possibly out of scope
for your library?

Thanks,
Joerg


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