Boost logo

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>> 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¼°Ý¡•É•…́ѡ”)™½±±½Ý¥¹œÝ½É­Ì…́•áÁ•Ñ•è()µÕ±Ñ¥}¥¹‘•á}½¹Ñ…¥¹•Èñ¥¹Ð°¸¸¸ø´ì(¸¸¸)½¹ÍЁ¥¹Ð˜àô¨¡´¹™¥¹ ¸¸¸¤¤ì)…ÕѼ¥Ðõ´¹¥Ñ•É…ѽÉ}Ѽ¡à¤ì()Ñ¡”™½±±½Ý¥¹œ‘½•Ì¹½Ðè()µÕ±Ñ¥}¥¹‘•á}½¹Ñ…¥¹•Èñ¥¹Ð°¸¸¸ø´ì(¸¸¸)¥¹Ðàô¨¡´¹™¥¹ ¸¸¸¤¤ì)…ÕѼ¥Ðõ´¹¥Ñ•É…ѽÉ}Ѽ¡à¤ì€¼¼Õ¹‘•™¥¹•‰•¡…Ù¥½È()‰•…ÕÍ”à¥Ì„½Á䁽˜„Ù…±Õ”¥¹Í¥‘”´°¹½Ð„É•™•É•¹”Ñ¼Ñ¡”Ù…±Õ”)¥ÑÍ•±˜°Ý¡¥ ¥ÌÝ¡…Ё¥Ñ•É…ѽÉ}ѼÉ•Åեɕ̸())½…Å×µ¸43ÍÁ•è5׎è)Q•±•›͹¥„

Boost-users list run by williamkempf at, kalb at, bjorn.karlsson at, gregod at, wekempf at