本文整理汇总了C++中SimpleList::Number方法的典型用法代码示例。如果您正苦于以下问题:C++ SimpleList::Number方法的具体用法?C++ SimpleList::Number怎么用?C++ SimpleList::Number使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SimpleList
的用法示例。
在下文中一共展示了SimpleList::Number方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: strlen
bool
MyString::replaceString(
const char *pszToReplace,
const char *pszReplaceWith,
int iStartFromPos)
{
SimpleList<int> listMatchesFound;
int iToReplaceLen = strlen(pszToReplace);
if (!iToReplaceLen) {
return false;
}
int iWithLen = strlen(pszReplaceWith);
while (iStartFromPos <= Len){
iStartFromPos = find(pszToReplace, iStartFromPos);
if (iStartFromPos == -1)
break;
listMatchesFound.Append(iStartFromPos);
iStartFromPos += iToReplaceLen;
}
if (!listMatchesFound.Number())
return false;
int iLenDifPerMatch = iWithLen - iToReplaceLen;
int iNewLen = Len + iLenDifPerMatch * listMatchesFound.Number();
char *pNewData = new char[iNewLen+1];
int iItemStartInData;
int iPosInNewData = 0;
int iPreviousEnd = 0;
listMatchesFound.Rewind();
while(listMatchesFound.Next(iItemStartInData)) {
memcpy(pNewData + iPosInNewData,
Data + iPreviousEnd,
iItemStartInData - iPreviousEnd);
iPosInNewData += (iItemStartInData - iPreviousEnd);
memcpy(pNewData + iPosInNewData, pszReplaceWith, iWithLen);
iPosInNewData += iWithLen;
iPreviousEnd = iItemStartInData + iToReplaceLen;
}
memcpy(pNewData + iPosInNewData,
Data + iPreviousEnd,
Len - iPreviousEnd + 1);
delete [] Data;
Data = pNewData;
capacity = iNewLen;
Len = iNewLen;
return true;
}
示例2:
int
allAmazonCommands(StringList &output)
{
AmazonGahpCommand *one_cmd = NULL;
amazon_gahp_commands.Rewind();
while( amazon_gahp_commands.Next(one_cmd) ) {
output.append(one_cmd->command.c_str());
}
return amazon_gahp_commands.Number();
}