|
Boost Users : |
From: Joaquín Mª López Muñoz (joaquin_at_[hidden])
Date: 2006-02-17 02:47:51
Aashit Soni ha escrito:
> Some correction!! in my previous mail.
>
> Thank you Mr Lopez,
>
> > Slower in which aspect? Insertion, deletion, lookup?
> I have observed it is slower in insertion. I am roughly creating some
> 200,000 entries into it. One entry is arround 10 Bytes of information. Each
> creation also creates some external objects to that are being cached
> in this container.
Well, it's hard to say. Note that if you're comparing a preexistent hash
table with a multi_index_container composed of a hashed plus
an ordered index, the comparison is not fair --the multi-index
container is doing more work. On the other hand, it is perfectly possible
that your previous hash container is just faster, but I don't think it
can be *much* faster. If you can provide me (through the list or privately)
with some test code I can take a deeper look.
> - I am having iteration problem in hash -look up also. My hash index is
> non_unique. I am not sure how the collisions are handled?
non_unique means equivalent elements (elements with the same key) are
allowed into the container.
In the particular case of hashed indices, equivalent elements are guaranteed
to be adjacent.
> When i call
> find and if the collisions are there i get the last inserted node,
> how shall i get previously inserted nodes.
Use equal_range() to get all of them. As explained above, equivalent
elements are kept adacent.
> In some case, i need to reserve the space for the elements, So when i
> create my multi_index container, i want to tell it saying that i need
> x amount of space so please do the allocation and keep it ready. Is
> such facility available.
No such facility, sorry. This preallocation stuff is not in the spirit
of node-based STL containers. You might gain some performance
by using custom allocators specialized for small node requests:
take a look for instance at boost::fast_pool_allocator:
http://boost.org/libs/pool/doc/interfaces/pool_alloc.html
> I will just incorporate- your sugguesion and check how it is working.
>
> Thank you once again, I really appreciate your time.
> regards,
> aashit
Good luck,
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
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