Subject: [Boost-bugs] [Boost C++ Libraries] #5641: Multiple keys in same index for same value in multi_index
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2011-06-24 21:42:20
#5641: Multiple keys in same index for same value in multi_index
--------------------------------------------+-------------------------------
Reporter: Aaron Moss <moss.aaron@â¦> | Owner: joaquin
Type: Feature Requests | Status: new
Milestone: To Be Determined | Component: multi_index
Version: Boost 1.46.1 | Severity: Not Applicable
Keywords: |
--------------------------------------------+-------------------------------
I have a collection of data objects analogous to this one:
{{{#!c++
struct foo {
bar b;
std::set<baz> s;
quux q;
};
}}}
which I want to be able to efficiently search either by b, or any element
of s (q is extra information). The natural way to do that would be some
sort of multi_index-like container, where I have a hash-map of bar to foo
(with one key per value), and another hash-map of baz to foo (with
multiple keys mapping to the same foo).
I may be mistaken, but I don't believe the second map can be set up
(efficiently, in its obvious implementation) in the current multi_index.
However, if it is allowable to have different sizes for different views of
the same collection / different numbers of keys of the same index mapping
to the same value, it would perhaps be a useful capability.
Without looking at the Boost sources, this would probably involve
generalizing key extractors to support multiple keys from the same value,
with syntax looking something like the following:
{{{#!c++
typedef multi_index_container<
foo,
indexed_by<
hashed_unique<
member<foo, bar, &foo::b>
>,
hashed_unique<
member_collection<foo, std::set<baz>::iterator, &foo::s.begin,
&foo::s.end>
>
>
> my_map;
}}}
-- Ticket URL: <https://svn.boost.org/trac/boost/ticket/5641> Boost C++ Libraries <http://www.boost.org/> Boost provides free peer-reviewed portable C++ source libraries.
This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:06 UTC