Hello Joaquin,
I have a class like below that uses mult-index container's find
method. I have a record pattern as below initially:
Idx : 100 Flag : 5
Idx : 200 Flag : 5
Idx : 300 Flag : 5
Idx : 400 Flag : 5
I modify the flag for index 100 to 6 & take a dump, the change is OK
Idx : 100 Flag : 6
Idx : 200 Flag : 5
Idx : 300 Flag : 5
Idx : 400 Flag : 5
I modify the flag for 100 back to 5 and take a dump, which is also fine.
Idx : 100 Flag : 5
Idx : 200 Flag : 5
Idx : 300 Flag : 5
Idx : 400 Flag : 5
Now I do a find based on flag value set to 5 I get the results as below:
Idx : 200 flag : 5
While find functionally is correct in picking up the correct data, but
I am wondering why it doesnt pick the first record (100) which has the
flag value set to 5? am I missing something in the indexing definition
in the container itself?
Thanks
/R
=========================
using namespace std;
#include
tToken;
class TokenMaster {
tToken TokenContainer;
public:
unsigned long getByFlag(unsigned long useFlag);
bool modify(unsigned long idx, unsigned char flag);
bool insert(unsigned long, unsigned char);
void dump();
};
unsigned long TokenMaster::getByFlag(unsigned long useFlag) {
typedef tToken::index<mflag>::type itflag;
itflag& mflag_index = TokenContainer.get<mflag>();
tToken::index_iterator<mflag>::type flagit = mflag_index.find(useFlag);
if (flagit == mflag_index.end()) {
return 0;
}
printf("Idx : %d flag : %d\n", flagit->mIdx, flagit->mflag);
return flagit->mIdx;
}
bool TokenMaster::modify(unsigned long idx, unsigned char flag) {
tToken::iterator itIp=TokenContainer.find(idx);
if (itIp == TokenContainer.end())
return false;
return TokenContainer.modify(itIp,(&ll::_1)->*&Token::mflag=flag);
}
bool TokenMaster::insert(unsigned long idx, unsigned char flag) {
tToken::iterator it;
bool secres;
std::pair