Iterate over all matching items with hashed_non_unique

I have a boost_multi_index with a hashed_non_unique key. I understand that if I do a .find() for a particular key, I can get a single entry with that key. However, I want to iterate over *ALL* the entries with this particular key, since there may be several. How do I do this? I can't figure out which is the correct end iterator. e.g. something along the following lines [haven't tried to compile] typedef FirstName string; typedef multi_index_container< Employee, indexed_by< hashed_non_unique<member<tag<FirstName>, Employee,FirstName,&Employee::first_name> > > > employee_set; typedef employee_set::index<FirstName>::type example_set_by_movie; boost::multi_index::get<FirstName>(m_employees).find("john"); -- http://www.cs.nyu.edu/~turian/

----- Mensaje original ----- De: Joseph Turian <turian@gmail.com> Fecha: Jueves, Noviembre 23, 2006 7:34 pm Asunto: [Boost-users] Iterate over all matching items with hashed_non_unique Para: boost-users@lists.boost.org
I have a boost_multi_index with a hashed_non_unique key.
I understand that if I do a .find() for a particular key, I can get a single entry with that key. However, I want to iterate over *ALL* the entries with this particular key, since there may be several. How do I do this?
I think .equal_range() is what you need. This member function returns a pair of iterators signalling the first and one past the last element with the given key. You can consult the reference http://boost.org/libs/multi_index/doc/reference/hash_indices.html for further details. HTH, Joaquín M López Muñoz Telefónica, Investigación y Desarrollo

Yes, that worked great, thanks! On 11/23/06, "JOAQUIN LOPEZ MU?Z" <joaquin@tid.es> wrote:
----- Mensaje original ----- De: Joseph Turian <turian@gmail.com> Fecha: Jueves, Noviembre 23, 2006 7:34 pm Asunto: [Boost-users] Iterate over all matching items with hashed_non_unique Para: boost-users@lists.boost.org
I have a boost_multi_index with a hashed_non_unique key.
I understand that if I do a .find() for a particular key, I can get a single entry with that key. However, I want to iterate over *ALL* the entries with this particular key, since there may be several. How do I do this?
I think .equal_range() is what you need. This member function returns a pair of iterators signalling the first and one past the last element with the given key. You can consult the reference
http://boost.org/libs/multi_index/doc/reference/hash_indices.html
for further details. HTH,
Joaquín M López Muñoz Telefónica, Investigación y Desarrollo _______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
participants (2)
-
"JOAQUIN LOPEZ MU?Z"
-
Joseph Turian