本文整理汇总了C++中VS::push_back方法的典型用法代码示例。如果您正苦于以下问题:C++ VS::push_back方法的具体用法?C++ VS::push_back怎么用?C++ VS::push_back使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类VS
的用法示例。
在下文中一共展示了VS::push_back方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: update
static bool update( VS& v ) {
int n = v.size();
if ( n <= 1 ) {
return false;
}
if ( n == 2 ) {
if ( check(v[0], v[1]) ) {
VS nv;
nv.push_back(v[0] + v[1]);
v = nv;
return true;
}
return false;
}
string tmp = "";
for ( auto i = 0; i + 1 < n; ++ i ) {
tmp += v[i];
if ( check(tmp, v[i + 1]) ) {
VS nv;
nv.push_back(tmp);
for ( int j = i + 1; j < n; ++ j ) {
nv.push_back(v[j]);
}
v = nv;
return true;
}
}
return false;
}
示例2: addQuad
void Mesh::addQuad(float width, float height) {
int indexOffset = positions.size();
float x = width / 2.0f;
float y = height / 2.0f;
VVec4 quad;
// C++11 { glm::vec3(-x, -y, 0), glm::vec3(x, -y, 0), glm::vec3(x, y, 0), glm::vec3(-x, y, 0), });
quad.push_back(glm::vec4(-x, -y, 0, 1));
quad.push_back(glm::vec4(x, -y, 0, 1));
quad.push_back(glm::vec4(x, y, 0, 1));
quad.push_back(glm::vec4(-x, y, 0, 1));
// Positions are transformed
add_all_transformed(model.top(), positions, quad);
if (normals.size()) {
// normals are transformed with only the rotation, not the translation
model.push().untranslate();
add_all_transformed(model.top(), normals, quad);
model.pop();
}
// indices are copied and incremented
VS quadIndices;
// C++11 VS( { 0, 1, 2, 0, 2, 3 } );
quadIndices.push_back(0);
quadIndices.push_back(1);
quadIndices.push_back(2);
quadIndices.push_back(0);
quadIndices.push_back(2);
quadIndices.push_back(3);
add_all_incremented(indexOffset, indices, quadIndices);
fillColors();
fillNormals();
}
示例3: splt
VS splt(std::string s, char c = ',') {
VS all;
int p = 0, np;
while (np = (int)s.find(c, p), np >= 0) {
if (np != p)
all.push_back(s.substr(p, np - p));
else
all.push_back("");
p = np + 1;
}
if (p < s.size())
all.push_back(s.substr(p));
return all;
}
示例4: replyVector
VS replyVector() {
VS ret;
return ret;
ret.push_back("titi");
ret.push_back("tutu");
return ret;
}
示例5: main
void main()
{
string strWord,strKey;int i;MSVS msvsDictionary;
while(cin>>strWord)
{
if(strWord.compare("XXXXXX")==0)break;
strKey=strWord;sort(strKey.begin(),strKey.end());
if(msvsDictionary.find(strKey)==msvsDictionary.end())
{
VS vsList;vsList.push_back(strWord);
msvsDictionary.insert(MSVS::value_type(strKey,vsList));
}
else msvsDictionary[strKey].push_back(strWord);
}
while(cin>>strKey)
{
if(strKey.compare("XXXXXX")==0)break;
sort(strKey.begin(),strKey.end());
if(msvsDictionary.find(strKey)==msvsDictionary.end())cout<<"NOT A VALID WORD"<<endl;
else
{
sort(msvsDictionary[strKey].begin(),msvsDictionary[strKey].end());
for(i=0;i<msvsDictionary[strKey].size();i++)
cout<<msvsDictionary[strKey][i]<<endl;
}
cout<<"******"<<endl;
}
}
示例6: main
int main() {
int m, n;
int i, j, k;
int max_subfile, max_file;
string s, x;
//freopen("f:\\in.txt", "r", stdin);
while (cin >> s) {
flist.clear();
for (i=3; s[i]; ++i) {
if (s[i] == '\\') flist.push_back(s.substr(0, i));
}
n = flist.size();
for (i=0; i!=n; ++i) {
if (fc.find(flist[i]) == fc.end()) {
for (j=0; j!=i; ++j) {
if (subfile.find(flist[j]) == subfile.end()) subfile.insert(make_pair(flist[j], 1));
else ++subfile[flist[j]];
}
fc.insert(flist[i]);
}
if (file.find(flist[i]) == file.end()) file.insert(make_pair(flist[i], 1));
else ++file[flist[i]];
}
}
max_subfile = 0, max_file = 0;
for (MSII it=subfile.begin(); it!=subfile.end(); ++it) max_subfile = max(max_subfile, it->second);
for (MSII it=file.begin(); it!=file.end(); ++it) max_file = max(max_file, it->second);
printf("%d %d\n", max_subfile, max_file);
return 0;
}
示例7: convert
VS convert( string s ) {
VS res;
ISS iss(s);
string word;
while ( iss >> word )
res.push_back(word);
return res;
}
示例8: split
VS split( string s, string c )
{
VS ret;
for( int i=0, n; i <= s.length(); i=n+1 ){
n = s.find_first_of( c, i );
if( n == string::npos ) n = s.length();
string tmp = s.substr( i, n-i );
ret.push_back(tmp);
}
return ret;
}
示例9: replyMap2
MSM replyMap2() {
MSM ret;
VS v;
return ret;
v.push_back("titi");
v.push_back("tutu");
ret["titi"] = v;
ret["tutu"] = v;
return ret;
}
示例10: main
int main(){
int i, n; char buff[MAXL]; VS code;
while(scanf("%d", &n) == 1){
code.clear();
for(i = 0; i < n; i++){
scanf(" %s", buff);
code.push_back(buff);
}
printf("[%s]\n", UDFind(code).c_str());
}
return 0;
}
示例11: _getPara
/*Get the parameter starting with key in record a*/
VS LogEntry::_getPara(const string &a)
{
int start, end, i;
start= a.find('(');
start++;
i = start;
end=a.find(')');
this->strPara = a.substr(start, end-start);
VS result;
while(i < end) {
if(a[i] == ',') {
result.push_back(a.substr(start, i-start));
start = i + 1;
}
i++;
}
result.push_back(a.substr(start, i-start));
return result;
}
示例12: split
static VS split( const std::string& s ) {
VS res;
string rs = s;
std::reverse(begin(rs), end(rs));
string tmp;
for ( auto c : rs ) {
tmp += c;
if ( c != '0' ) {
std::reverse(begin(tmp), end(tmp));
res.push_back(tmp);
tmp = "";
}
}
if ( tmp != "" ) {
std::reverse(begin(tmp), end(tmp));
res.push_back(tmp);
tmp = "";
}
std::reverse(begin(res), end(res));
while ( res.size() >= 2 ) {
bool flag = false;
if ( res[0].size() == res[1].size() && res[0] < res[1] ) {
flag = true;
} else if ( res[0].size() < res[1].size() ) {
flag = true;
}
if ( flag ) {
// cout << "res = " << res[0] << " / " << res[1] << endl;
res[0] += res[1];
res.erase(begin(res) + 1);
} else {
break;
}
}
while ( update(res) );
return res;
}
示例13: CalcMatrix
void CalcMatrix(const vector<CompositeData> data, VVI & RM, VVI & DM,
VS & deci_val) {
if (data.size() == 0 ) {
cerr << "Input data is empty!" << endl;
exit(-1);
}
unsigned int i, j;
//Calc Relation Matrix
RM.clear();
VI vbTmp(data.size(), 0);
RM.insert(RM.begin(), data.size(), vbTmp);
for (i = 0; i < data.size(); ++i) {
for (j = 0; j < data.size(); ++j) {
if (data[i] == data[j])
RM[i][j] = 1;
}
RM[i][i] = 1;
}
//Calc Relation Matrix
STR2VI_MAP DMap;
STR2VI_MAP::iterator it;
for (i = 0; i < data.size(); ++i) {
it = DMap.find(data[i].d);
if (it == DMap.end()) {
VI tmp;
tmp.push_back(i);
DMap.insert(STR2VI_MAP::value_type(data[i].d, tmp));
} else {
((*it).second).push_back(i);
}
}
//DM: n * d
//DMap.size() = d
DM.clear();
VI viTmp(DMap.size(), 0);
DM.insert(DM.begin(), data.size(), viTmp);
// cout << DM.size() << "\t" << DM[0].size() << endl;
for (i = 0, it = DMap.begin(); it != DMap.end(); ++it, ++i) {
deci_val.push_back((*it).first);
for (j = 0; j < (*it).second.size(); ++j) {
DM[(*it).second[j]][i] = 1;
}
}
DMap.clear();
}
示例14: print
VS print(VVI & m) {
VS M;
for (int i = 0; i < (int)m.size(); i++) {
M.push_back("");
for (int j = 0; j < (int)m[i].size(); j++) {
ostringstream os;
os << m[i][j];
if (j == 0) M[i] += os.str();
else M[i] += (" " + os.str());
}
}
//for (int i = 0; i < (int)M.size(); i++)
//cout << M[i] << endl;
return M;
}
示例15: token
vector <string> token( string str,string deli )
{
char * cstr, *p,*deli_c;
deli_c = new char [deli.size()+1];
cstr = new char [str.size()+1];
strcpy(deli_c,deli.c_str());
strcpy (cstr, str.c_str());
VS vec;
p=strtok(cstr,deli_c);
while(p!=NULL)
{
vec.push_back( string(p));
p=strtok(NULL,deli_c);
}
delete[] cstr;
return vec;
}