Set and Multiset map and Multimap have member functions find function to quickly locate
Vector and list no find functions want to find traversal through iterators
The following uses the class overloading operator to implement FIND_IF quick lookups:
typedef struct STRTMPLINKMAN
{
CString Tmplinkmanname;
CString Tmplinkmaneemail;
}strtmplinkman;
typedef std::list<strtmplinkman> TMPLINKMAN_T;
typedef std::list<strtmplinkman>::iterator tmplinkmaniter_t;
Class Findthevalstring
{
Does the STL find Tmplinkmanemail contain
Public
Findthevalstring (CString str): M_linkmanemail (str) {};
BOOL Operator () (const Strtmplinkman &t) const
{
return m_linkmanemail = = T.tmplinkmaneemail;
}
Private
CString M_linkmanemail;
};
typedef struct STRTMPGROUP
{
Strtmpgroup ()
{
PList = NULL;
}
CString Strtmpgroupname;
clistuiex* pList;
Tmplinkman_t strtmplinklist;
}strtmpgroup;
typedef std::list<strtmpgroup> STRTMPGROUPLIST_T;
typedef std::list<strtmpgroup>::iterator strtmpgroupiter_t;
Class Findtheval
{
The STL finds whether clistuiex* plist contains
Public
Findtheval (clistuiex* x): M_age (x) {};
BOOL Operator () (const strtmpgroup &t) const
{
return m_age = = T.plist;
}
Private
clistuiex* M_age;
};
typedef struct STGROUPUSER_T
{
stgroupuser_t ()
{
Ptmpgrouplist = NULL;
}
strtmpgrouplist_t* ptmpgrouplist;
}stgroupuser_t;
extern stgroupuser_t G_sttmpgroupinfo;
Std::list<strtmpgroup>::iterator finded_plist = find_if (G_sttmpgroupinfo.ptmpgrouplist->begin (), g_ Sttmpgroupinfo.ptmpgrouplist->end (), Findtheval (prightlist));
if (finded_plist! = G_sttmpgroupinfo.ptmpgrouplist->end ())
{
Found it
Find out if there is the same string linkmanemail
Std::list<strtmplinkman>::iterator finded_string = find_if (Itertmpgroupinfo->strtmplinklist.begin (), Itertmpgroupinfo->strtmplinklist.end (), findthevalstring (Sttmplinkman.tmplinkmaneemail));
if (finded_string = = Itertmpgroupinfo->strtmplinklist.end ())
{
Not found.
}
}
STL list using find_if lookup algorithm