Quantcast

Boost MultiIndex slow mass insertion

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Boost MultiIndex slow mass insertion

Boost - Dev mailing list
I have the following structure:

typedef boost::multi_index_container<
    MyClass,
    boost::multi_index::indexed_by<
        boost::multi_index::hashed_unique<boost::multi_index::member<MyClass, int, &amp;MyClass::label>>,
        boost::multi_index::ordered_non_unique<boost::multi_index::member<MyClass, double, &amp;MyClass::dist>>      
    >
> MyClassSet;

If i populate it in a loop:

MyClassSet all:
for (int y = 0; y < input.rows; ++y) {
    MyClass c;
    // ....
    all.insert(c);
}

the insertion time is quite slow. It probably need to continuously re-order the underlying implementation.
Anyway i would expect that populating it with a single call it would be faster (e.g. sorting the whole set only at the end).
Example:

std::vector<MyClass> vec;
// ...
MyClassSet all(vec.begin(), vec.end());

BUT... the times are almost equal.

My question is: is this intended behaviour?
Is there a faster way to mass populate the container (e.g. not enforcing the invariants/orderings at each 'insert')?



_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Boost MultiIndex slow mass insertion

Boost - Dev mailing list


_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
Loading...