2.1.2.14 is_in_list
Description
Check and see if given string is in the list.
Check and see if given double value is in the vector.
Syntax
bool is_in_list( LPCSTR lpcszName, const vector<string> & vsList, bool bCaseSensitive = false, int * pn = NULL )
bool is_in_list(vectorbase& vecList, double dVal)
Parameters
- lpcszName
- [input] a C string with NULL ended or a string to be checked if in the list
- vsList
- [input] string list to be searched
- bCaseSensitive
- [input] whether the string comparison is case sensitive or not
- pn
- [output] pointer to a integer which is the index of the found string when the function successfully return.
- vecList
- [input] the vector be to find
- dVal
- [input] the value to be checked in vector
Return
returns true if lpcszName is found in vsList, otherwise false.
returns true if dVal is found in vector, otherwise false.
Examples
EX1
int is_in_list_ex1()
{
vector<string> vsPlaces = {"ShangHai","Shanghai","UK","LA","London","Pary"};
int iIndex;
if(is_in_list("UK", vsPlaces,true,&iIndex))
printf("%d\n",iIndex);//Should print 2 since the index starts from 0
string strPlace = "ShangHai";
if(is_in_list(strPlace,vsPlaces,true,&iIndex))
printf("%d\n",iIndex);//Should print 0 since the index starts from 0
return 0;
}
Remark
See Also
find_in_list
Header to Include
origin.h
Reference
|