本文整理汇总了C++中strArray::size方法的典型用法代码示例。如果您正苦于以下问题:C++ strArray::size方法的具体用法?C++ strArray::size怎么用?C++ strArray::size使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类strArray
的用法示例。
在下文中一共展示了strArray::size方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: mult
void mult(strArray &a, strArray &b)
{
strArray c(a); a.clear();
for (int i = 0; i < c.size(); i ++)
for (int j = 0; j < b.size(); j ++)
a.push_back(c[i] + b[j]);
};
示例2: splitWithForm
// first, judge whether the form of the string like this: {x,y}
// if the form is right,the string will be split into the parameter strs;
// or the parameter strs will be empty.
// if the form is right return true,else return false.
// 首先,判断表格的字符串是否为{x,y}
// 是,则使用分裂字符串到参数strs
// 否则参数strs为空;
// 表格是对的,则返回true
static bool splitWithForm(const char* pStr, strArray& strs)
{
bool bRet = false;
do
{
CC_BREAK_IF(!pStr);
// string is empty
// 字符串为空
std::string content = pStr;
CC_BREAK_IF(content.length() == 0);
int nPosLeft = content.find('{');
int nPosRight = content.find('}');
// don't have '{' and '}'
// 不含有{}
CC_BREAK_IF(nPosLeft == (int)std::string::npos || nPosRight == (int)std::string::npos);
// '}' is before '{'
// }在{前
CC_BREAK_IF(nPosLeft > nPosRight);
std::string pointStr = content.substr(nPosLeft + 1, nPosRight - nPosLeft - 1);
// nothing between '{' and '}'
// 在{}之前没有任何参数
CC_BREAK_IF(pointStr.length() == 0);
int nPos1 = pointStr.find('{');
int nPos2 = pointStr.find('}');
// contain '{' or '}'
// 包含{}
CC_BREAK_IF(nPos1 != (int)std::string::npos || nPos2 != (int)std::string::npos);
split(pointStr, ",", strs);
if (strs.size() != 2 || strs[0].length() == 0 || strs[1].length() == 0)
{
strs.clear();
break;
}
bRet = true;
} while (0);
return bRet;
}
示例3: splitWithForm
// first, judge whether the form of the string like this: {x,y}
// if the form is right,the string will be split into the parameter strs;
// or the parameter strs will be empty.
// if the form is right return true,else return false.
static KDbool splitWithForm ( const KDchar* szString, strArray& vStrings )
{
KDbool bRet = KD_FALSE;
do
{
CC_BREAK_IF ( !szString );
// string is empty
std::string sContent = szString;
CC_BREAK_IF ( sContent.length ( ) == 0 );
KDuint nPosLeft = sContent.find ( '{' );
KDuint nPosRight = sContent.find ( '}' );
// don't have '{' and '}'
CC_BREAK_IF ( nPosLeft == std::string::npos || nPosRight == std::string::npos );
// '}' is before '{'
CC_BREAK_IF ( nPosLeft > nPosRight );
std::string sPointStr = sContent.substr ( nPosLeft + 1, nPosRight - nPosLeft - 1 );
// nothing between '{' and '}'
CC_BREAK_IF ( sPointStr.length ( ) == 0 );
KDuint nPos1 = sPointStr.find ( '{' );
KDuint nPos2 = sPointStr.find ( '}' );
// contain '{' or '}'
CC_BREAK_IF ( nPos1 != std::string::npos || nPos2 != std::string::npos );
split ( sPointStr, ",", vStrings );
if ( vStrings.size ( ) != 2 || vStrings [ 0 ].length ( ) == 0 || vStrings [ 1 ].length ( ) == 0 )
{
vStrings.clear ( );
break;
}
bRet = KD_TRUE;
} while ( 0 );
return bRet;
}
示例4: splitWithForm
// first, judge whether the form of the string like this: {x,y}
// if the form is right,the string will be split into the parameter strs;
// or the parameter strs will be empty.
// if the form is right return true,else return false.
static bool splitWithForm(const std::string& content, strArray& strs)
{
bool bRet = false;
do
{
CC_BREAK_IF(content.empty());
size_t nPosLeft = content.find('{');
size_t nPosRight = content.find('}');
// don't have '{' and '}'
CC_BREAK_IF(nPosLeft == std::string::npos || nPosRight == std::string::npos);
// '}' is before '{'
CC_BREAK_IF(nPosLeft > nPosRight);
const std::string pointStr = content.substr(nPosLeft + 1, nPosRight - nPosLeft - 1);
// nothing between '{' and '}'
CC_BREAK_IF(pointStr.length() == 0);
size_t nPos1 = pointStr.find('{');
size_t nPos2 = pointStr.find('}');
// contain '{' or '}'
CC_BREAK_IF(nPos1 != std::string::npos || nPos2 != std::string::npos);
split(pointStr, ",", strs);
if (strs.size() != 2 || strs[0].length() == 0 || strs[1].length() == 0)
{
strs.clear();
break;
}
bRet = true;
} while (0);
return bRet;
}
示例5: add
void add(strArray &a, const strArray &b)
{
for (int i = 0; i < b.size(); i ++)
a.push_back(b[i]);
};
示例6: print
void print(strArray &answer)
{
if (answer.size()) printf("%s", answer[0].c_str());
for (int i = 1; i < answer.size(); i++) printf("+%s", answer[i].c_str());
printf("\n");
};