|
Boost Users : |
Subject: Re: [Boost-users] multi_index:iterator_to complexity
From: Joaquin M Lopez Munoz (joaquin_at_[hidden])
Date: 2015-03-09 03:02:19
Matwey V. Kornilov <matwey.kornilov <at> gmail.com> writes:
>
>
> Hi,
>
> The following two calls have constant complexity (according to docs) for
> all indices:
>
> iterator iterator_to(const value_type& x);
> const_iterator iterator_to(const value_type& x) const;
Correct, these are constant complexity.
> As far as I understand, the single way to reach the constant complexity
> in searching by pointer is to store the objects in continuous memory area.
>
> Is it correct?
No, it's not correct. In fact, elements in a multi_index_container are
*not* stored contiguously.
iterator_to does not do any kind of search based on x, but takes a reference
to an element of the container and returns an iterator to it (roughly
speaking, converts ±µ¹ÐÁ½¥¹ÑÈѼ¹½Á½¥¹ÑȤ¸M¼°Ý¡É
ÌÑ¡)½±±½Ý¥¹Ý½ÉÌ
ÌáÁÑè()µÕ±Ñ¥}¥¹á}½¹Ñ
¥¹Èñ¥¹Ð°¸¸¸ø´ì(¸¸¸)½¹ÍÐ¥¹Ðàô¨¡´¹¥¹ ¸¸¸¤¤ì)
ÕѼ¥Ðõ´¹¥ÑÉ
ѽÉ}Ѽ¡à¤ì()Ñ¡½±±½Ý¥¹½Ì¹½Ðè()µÕ±Ñ¥}¥¹á}½¹Ñ
¥¹Èñ¥¹Ð°¸¸¸ø´ì(¸¸¸)¥¹Ðàô¨¡´¹¥¹ ¸¸¸¤¤ì)
ÕѼ¥Ðõ´¹¥ÑÉ
ѽÉ}Ѽ¡à¤ì¼¼Õ¹¥¹¡
Ù¥½È()
ÕÍà¥Ì½Áä½Ù
±Õ¥¹Í¥´°¹½ÐÉɹѼѡÙ
±Õ)¥Ñͱ°Ý¡¥ ¥ÌÝ¡
Ð¥ÑÉ
ѽÉ}ѼÉÅÕ¥É̸())½
Å×µ¸43ÍÁè5׎è)Q±Í¹¥
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