I created a boost multi_index in which I am inserting objects.
My multi_index looks as follows,
typedef boost::multi_index_container<
Container*,
boost::multi_index::indexed_by<
boost::multi_index::hashed_unique<
boost::multi_index::tag<IndexByUniqueId>,
boost::multi_index::const_mem_fun<StoreMe, Id, &StoreMe::getUId>
>,
boost::multi_index::hashed_non_unique<
boost::multi_index::tag<IndexByNonUId>,
boost::multi_index::const_mem_fun<StoreMe, std::string, &Container::getNUIdString>
>
>
> mi_Container;
When I insert objects the non-unique ID and the unique IDs are not present in the object initially. Later in the course of the program they get updated and only after that "getNUIdString" and "getUId" would return 0/non-empty values.
In that case when I try to look up using the non-unique ID I am not able to get the value stored. Is it expected that they are filled at the time of insertion? Or is it fine if they are updated as and when they are required and I can still look up my the value at that moment?
Edit1:
I understand that I would need to update the index using "replace" or "modify" while the index is changed. So is it that it initially while inserting inserts with empty string as the key for one index and 0 for the other index, and when I look up using a specific value it doesnt return me anything? Which means if I look up using the empty string "". It should return me all the values(and thus would be lookup time O(n))?
Edit2: I tried getting all the values mapped to "", empty string. I still get no results. The first of the pair of iterators is equal to the end().
Also if I wanted to change the value of the key for only one of the non_unique keys value pairs when the value is being set in the setter for that object, how would I do it? I would want to do it every time I set a value through the setter for an object, so that I am able to look it up using the multi_index I have.
TIA
-R