Is there an easy way to test two multi_index containers for equality, c1 == c2?
Hi Ted, ________________________________ De: boost-users-bounces@lists.boost.org [boost-users-bounces@lists.boost.org] En nombre de Ted Pederson [ted.pederson@gmail.com] Enviado el: viernes, 09 de mayo de 2008 18:03 Para: boost-users@lists.boost.org Asunto: [Boost-users] testing for multi_index equality
Is there an easy way to test two multi_index containers for equality, c1 == c2?
c1 == c2 is defined to be equivalent to c1.get<0>()==c2.get<0>(), which is defined if the first index of the container is of type ordered, sequenced or random access; in all these cases the expression is in fact equivalent to c1.size()==c2.size()&&std::equal(c1.begin(),c1.end(),c2.begin()); Is this not what you had in mind? Joaquín M López Muñoz Telefónica, Investigación y Desarrollo
Yes, newbie error. I had defined a < operator on my struct that is indexed
by multi_index. Once I defined == instead, everything is OK.
On Fri, May 9, 2008 at 9:53 AM, JOAQUIN M. LOPEZ MUÑOZ
Hi Ted,
------------------------------ *De:* boost-users-bounces@lists.boost.org [ boost-users-bounces@lists.boost.org] En nombre de Ted Pederson [ ted.pederson@gmail.com] *Enviado el:* viernes, 09 de mayo de 2008 18:03 *Para:* boost-users@lists.boost.org *Asunto:* [Boost-users] testing for multi_index equality
Is there an easy way to test two multi_index containers for equality, c1
== c2?
c1 == c2 is defined to be equivalent to c1.get<0>()==c2.get<0>(), which is defined if the first index of the container is of type ordered, sequenced or random access; in all these cases the expression is in fact equivalent to
c1.size()==c2.size()&&std::equal(c1.begin(),c1.end(),c2.begin());
Is this not what you had in mind?
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
Hi Joaquin,
does this mean that if the zeroth index is unordered or ordered but
non-unique you could have a false negative in the equality test due to
elements ordering being undefined?
Regards,
Francesco.
On Fri, May 9, 2008 at 6:53 PM, JOAQUIN M. LOPEZ MUÑOZ
Hi Ted,
------------------------------ *De:* boost-users-bounces@lists.boost.org [ boost-users-bounces@lists.boost.org] En nombre de Ted Pederson [ ted.pederson@gmail.com] *Enviado el:* viernes, 09 de mayo de 2008 18:03 *Para:* boost-users@lists.boost.org *Asunto:* [Boost-users] testing for multi_index equality
Is there an easy way to test two multi_index containers for equality, c1
== c2?
c1 == c2 is defined to be equivalent to c1.get<0>()==c2.get<0>(), which is defined if the first index of the container is of type ordered, sequenced or random access; in all these cases the expression is in fact equivalent to
c1.size()==c2.size()&&std::equal(c1.begin(),c1.end(),c2.begin());
Is this not what you had in mind?
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
________________________________ De: boost-users-bounces@lists.boost.org [boost-users-bounces@lists.boost.org] En nombre de francesco biscani [bluescarni@gmail.com] Enviado el: viernes, 09 de mayo de 2008 21:36 Para: boost-users@lists.boost.org Asunto: Re: [Boost-users] testing for multi_index equality
Hi Joaquin,
does this mean that if the zeroth index is unordered or ordered but non-unique you could have a false negative in the equality test due to elements ordering being undefined?
What do you mean by unordered? If the zeroth index is hashed, container equality will fail to compile. In all other cases, equality depends on the ordering of the elements, which is not strictly determined for ordered_non_unique, sequenced and random_access. This might not coincide with your required notion for equality. I simply mimicked the modus operandi of STL containers. Joaquín M López Muñoz Telefónica, Investigación y Desarrollo
On Fri, May 9, 2008 at 9:59 PM, JOAQUIN M. LOPEZ MUÑOZ
------------------------------ *De:* boost-users-bounces@lists.boost.org [ boost-users-bounces@lists.boost.org] En nombre de francesco biscani [ bluescarni@gmail.com] *Enviado el:* viernes, 09 de mayo de 2008 21:36 *Para:* boost-users@lists.boost.org *Asunto:* Re: [Boost-users] testing for multi_index equality
Hi Joaquin,
does this mean that if the zeroth index is unordered or ordered but
non-unique you could
have a false negative in the equality test due to elements ordering being undefined? What do you mean by unordered? If the zeroth index is hashed, container equality will fail to compile. In all other cases, equality depends on the ordering of the elements, which is not strictly determined for ordered_non_unique, sequenced and random_access. This might not coincide with your required notion for equality. I simply mimicked the modus operandi of STL containers.
Yes, that's what I meant to say :) Thanks and best regards, Francesco.
participants (3)
-
francesco biscani
-
JOAQUIN M. LOPEZ MUÑOZ
-
Ted Pederson