|
Boost Users : |
From: Dmitriy Bure (borech_at_[hidden])
Date: 2006-02-01 12:49:01
Hello,
I'm very interested to use multi_index container in my work. But didn't
found much documentation and\or examples. Maybe anyone could suggest a
place to find it?
Basically now I'm trying to implement probably very simple thing. There
is basic structure:
struct AvNode
{
CNode* var;
int context;
MemoryPlace location;
...
};
And I'd like to have multi_index container with such nodes (all fields
are non-equal). Something like this:
typedef multi_index_container<
AvNode,
indexed_by<
ordered_non_unique<
tag<varNcontextIndex>,
composite_key<
AvNode,
BOOST_MULTI_INDEX_MEMBER(AvNode,CNode*,var),
BOOST_MULTI_INDEX_MEMBER(AvNode,int,context)
>
>
>
> AvNodeSet;
And then I need to iterate on this container. Better to say that I'd
like to group elements in container by first two fields. Could you help
me in this problem? In fact I have one solution but it's too large and
non-fine:
AvNodeSet avNodes;
typedef index<AvNodeSet, varNcontextIndex>::type AvNodesSet2VarNcontext;
AvNodesSet2VarNcontext& avNodes2VarNcontext =
boost::multi_index::get<varNcontextIndex>(avNodes);
AvNodesSet2VarNcontext::iterator it = avNodes2VarNcontext.begin();
while(it != avNodes2VarNcontext.end())
{
CNode* var = it->var;
AvNodesSet2VarNcontext::iterator it2Var = it;
while( (it2Var != avNodes2VarNcontext.end()) && (it2Var ->var== var) )
{
int context = it2Var->context;
FOO(make_pair(var, context));
AvNodesSet2VarNcontext::iterator it2Context = it2Var;
while( (it2Context != avNodes2VarNcontext.end()) &&
(it2Context->context == context) )
{
++it2Context;
}
it2Var = it2Context;
}
it = it2Var;
}
Hope for your help...
-- Best regards, Dmitriy Bure mailto:borech_at_[hidden]
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