remove_if_in_list

 

Description

Filter a vector of strings by another , remove all those strings from the first vector.

Syntax

int remove_if_in_list( vector<string> & vsToCheck, const vector<string> & vsList, bool bCaseSensitive = false )

Parameters

vsToCheck
[modify]the string array to be checked and removed items
vsList
[input]the reference string array.
bCaseSensitive
[input]true to make the comparing case sensitive.

Return

number of element remains in vsToCheck.

Examples

EX1

void remove_if_in_list_ex1()
{
        vector<string>  vsToCheck ={"here","is","an","exmaple","only","for","remove_if_in_list()"};
        vector<string>  vsList ={"Here","is","an","exmaple"};       
        int nRet = remove_if_in_list(vsToCheck , vsList);
        if(nRet)
        {     
                printf("number of element remains is %d \n" ,nRet);
                //Should print "only for remove_if_in_list()"
                for(int ii = 0; ii < vsToCheck.GetSize(); ii++)
                  printf("%s " ,vsToCheck[ii]);
        }
        else
          printf("remove failed\n");      
}

Remark

See Also

remove_if_not_in_list

Header to Include

origin.h

Reference