本文整理汇总了C++中SList::clear方法的典型用法代码示例。如果您正苦于以下问题:C++ SList::clear方法的具体用法?C++ SList::clear怎么用?C++ SList::clear使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SList
的用法示例。
在下文中一共展示了SList::clear方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: userInfo
void Git::userInfo(SList info) {
/*
git looks for commit user information in following order:
- GIT_AUTHOR_NAME and GIT_AUTHOR_EMAIL environment variables
- repository config file
- global config file
- your name, hostname and domain
*/
const QString env(QProcess::systemEnvironment().join(","));
QString user(env.section("GIT_AUTHOR_NAME", 1).section(",", 0, 0).section("=", 1).trimmed());
QString email(env.section("GIT_AUTHOR_EMAIL", 1).section(",", 0, 0).section("=", 1).trimmed());
info.clear();
info << "Environment" << user << email;
errorReportingEnabled = false; // 'git config' could fail, see docs
run("git config user.name", &user);
run("git config user.email", &email);
info << "Local config" << user << email;
run("git config --global user.name", &user);
run("git config --global user.email", &email);
info << "Global config" << user << email;
errorReportingEnabled = true;
}
示例2: getLaneParentsChilds
bool HistoryView::getLaneParentsChilds(SCRef sha, int x, SList p, SList c) {
ListViewDelegate* lvd = static_cast<ListViewDelegate*>(itemDelegate());
uint lane = x / lvd->laneWidth();
int t = getLaneType(sha, lane);
if (t == EMPTY || t == -1)
return false;
// first find the parents
p.clear();
QString root;
if (!isFreeLane(t)) {
p = git->revLookup(sha, fh)->parents(); // pointer cannot be NULL
root = sha;
} else {
SCRef par(git->getLaneParent(sha, lane));
if (par.isEmpty()) {
dbs("ASSERT getLaneParentsChilds: parent not found");
return false;
}
p.append(par);
root = p.first();
}
// then find children
c = git->getChilds(root);
return true;
}
示例3: getFiles
bool CommitImpl::getFiles(SList selFiles) {
// check for files to commit
selFiles.clear();
QTreeWidgetItemIterator it(treeWidgetFiles);
while (*it) {
if ((*it)->checkState(0) == Qt::Checked)
selFiles.append((*it)->text(0));
++it;
}
return !selFiles.isEmpty();
}
示例4: insert
void VarEdgeInserterDynCore::insert(edge eOrig, SList<adjEntry>& eip)
{
eip.clear();
node s = m_pr.copy(eOrig->source());
node t = m_pr.copy(eOrig->target());
// find path from s to t in BC-tree
// call of blockInsert() is done when we have found the path
// if no path is found, s and t are in different connected components
// and thus an empty edge insertion path is correct!
DynamicSPQRForest& dSPQRF = m_pBC->dynamicSPQRForest();
SList<node>& path = dSPQRF.findPath(s, t);
if (!path.empty()) {
SListIterator<node> it = path.begin();
node repS = dSPQRF.repVertex(s, *it);
for (SListIterator<node> jt = it; it.valid(); ++it) {
node repT = (++jt).valid() ? dSPQRF.cutVertex(*jt, *it) : dSPQRF.repVertex(t, *it);
// less than 3 nodes requires no crossings (cannot build SPQR-tree
// for a graph with less than 3 nodes!)
if (dSPQRF.numberOfNodes(*it) > 3) {
List<adjEntry> L;
blockInsert(repS, repT, L); // call biconnected case
// transform crossed edges to edges in G
for (adjEntry kt : L) {
edge e = kt->theEdge();
eip.pushBack(e->adjSource() == kt ? dSPQRF.original(e)->adjSource()
: dSPQRF.original(e)->adjTarget());
}
}
if (jt.valid()) repS = dSPQRF.cutVertex(*it, *jt);
}
}
delete &path;
}
示例5: unittest
//.........这里部分代码省略.........
try
{
btassert<bool>(list.toString() == "10,20" && list.getSize() == 2);
cout << "Passed TEST 11: insertHead,insertTail,toString,getSize \n";
}
catch (bool b)
{
cout << "# FAILED TEST 11: insertHead,insertTail,toString,getSize #\n";
}
list.removeHead();
try
{
btassert<bool>(list.toString() == "20" && list.getSize() == 1);
cout << "Passed TEST 12: removeHead,toString,getSize \n";
}
catch (bool b)
{
cout << "# FAILED TEST 12: removeHead,toString,getSize #\n";
}
list.insertHead(10);
list.removeTail();
try
{
btassert<bool>(list.toString() == "10" && list.getSize() == 1);
cout << "Passed TEST 13: insertHead,removeTail,toString,getSize \n";
}
catch (bool b)
{
cout << "# FAILED TEST 13: insertHead,removeTail,toString,getSize #\n";
}
list.clear();
try
{
btassert<bool>(list.toString() == "" && list.getSize() == 0);
cout << "Passed TEST 13: clear,toString,getSize \n";
}
catch (bool b)
{
cout << "# FAILED TEST 13: clear,toString,getSize #\n";
}
list.insertHead(10);
list.insertHead(5);
list.insertTail(20);
list.insertTail(25);
try
{
btassert<bool>(list.toString() == "5,10,20,25" && list.getSize() == 4);
cout << "Passed TEST 14: insertHeadx2,insertTailx2,toString,getSize \n";
}
catch (bool b)
{
cout << "# FAILED TEST 14: insertHeadx2,insertTailx2,toString,getSize #\n";
}
list.removeHead();
list.removeTail();
list.removeHead();
list.removeTail();
list.clear();
try
{
btassert<bool>(list.toString() == "" && list.getSize() == 0);
示例6: unittest
/*
* Unit testing functions. Do not alter.
*/
void unittest ()
{
cout << "\nSTARTING UNIT TEST\n\n";
SList list;
try {
btassert<bool>(list.getSize() == 0);
cout << "Passed TEST 1: default constructor (size) \n";
} catch (bool b) {
cout << "# FAILED TEST 1: default constructor (size) #\n";
}
try {
btassert<bool>(list.toString() == "");
cout << "Passed TEST 2: toString \n";
} catch (bool b) {
cout << "# FAILED TEST 2: toString #\n";
}
list.removeHead();
try {
btassert<bool>(list.getSize() == 0);
cout << "Passed TEST 3: removeHead \n";
} catch (bool b) {
cout << "# FAILED TEST 3: removeHead #\n";
}
list.insertHead(1);
try {
btassert<bool>(list.getSize() == 1);
cout << "Passed TEST 4: insertHead \n";
} catch (bool b) {
cout << "# FAILED TEST 4: insertHead #\n";
}
try {
btassert<bool>(list.toString() == "1");
cout << "Passed TEST 5: toString \n";
} catch (bool b) {
cout << "# FAILED TEST 5: toString #\n";
}
list.removeHead();
try {
btassert<bool>(list.getSize() == 0);
cout << "Passed TEST 6: removeHead \n";
} catch (bool b) {
cout << "# FAILED TEST 6: removeHead #\n";
}
try {
btassert<bool>(list.toString() == "");
cout << "Passed TEST 7: toString \n";
} catch (bool b) {
cout << "# FAILED TEST 7: toString #\n";
}
list.insertHead(10);
list.insertHead(20);
try {
btassert<bool>(list.toString() == "20,10" && list.getSize() == 2);
cout << "Passed TEST 8: insertHead,insertHead,toString,getSize \n";
} catch (bool b) {
cout << "# FAILED TEST 8: insertHead,insertHead,toString,getSize #\n";
}
list.removeHead();
try {
btassert<bool>(list.toString() == "10" && list.getSize() == 1);
cout << "Passed TEST 9: removeHead,toString,getSize \n";
} catch (bool b) {
cout << "# FAILED TEST 9: removeHead,toString,getSize #\n";
}
list.insertHead(5);
try {
btassert<bool>(list.toString() == "5,10" && list.getSize() == 2);
cout << "Passed TEST 10: insertHead,toString,getSize \n";
} catch (bool b) {
cout << "# FAILED TEST 10: insertHead,toString,getSize #\n";
}
list.clear();
try {
btassert<bool>(list.toString() == "" && list.getSize() == 0);
cout << "Passed TEST 11: clear,toString,getSize \n";
} catch (bool b) {
cout << "# FAILED TEST 11: clear,toString,getSize #\n";
}
for (unsigned int i=0; i<1000; i++)
list.insertHead(i);
try {
btassert<bool>(list.getSize() == 1000);
cout << "Passed TEST 12: insertHead high load \n";
} catch (bool b) {
//.........这里部分代码省略.........
示例7: unittest
//.........这里部分代码省略.........
list.insert(20);
try {
btassert<bool>(list.getSize() == 6 && list.toString() == "5,10,20,30,50,55");
cout << "Passed TEST 8: insert(20)/getSize/toString \n";
} catch (bool b) {
cout << "# FAILED TEST 8: insert(20)/getSize/toString #\n";
}
list.insert(40);
try {
btassert<bool>(list.getSize() == 7 && list.toString() == "5,10,20,30,40,50,55");
cout << "Passed TEST 9: insert(40)/getSize/toString \n";
} catch (bool b) {
cout << "# FAILED TEST 9: insert(40)/getSize/toString #\n";
}
list.insert(30);
try {
btassert<bool>(list.getSize() == 8 && list.toString() == "5,10,20,30,30,40,50,55");
cout << "Passed TEST 10: insert(30)/getSize/toString \n";
} catch (bool b) {
cout << "# FAILED TEST 10: insert(30)/getSize/toString #\n";
}
list.insert(5);
try {
btassert<bool>(list.getSize() == 9 && list.toString() == "5,5,10,20,30,30,40,50,55");
cout << "Passed TEST 11: insert(5)/getSize/toString \n";
} catch (bool b) {
cout << "# FAILED TEST 11: insert(5)/getSize/toString #\n";
}
try {
btassert<bool>(list.removeFirst(1) == false);
cout << "Passed TEST 12: removeFirst(1) \n";
} catch (bool b) {
cout << "# FAILED TEST 12: removeFirst(1) #\n";
}
try {
btassert<bool>(list.removeFirst(5) == true && list.getSize() == 8 && list.toString() == "5,10,20,30,30,40,50,55");
cout << "Passed TEST 13: removeFirst(5)/getSize/toString \n";
} catch (bool b) {
cout << "# FAILED TEST 13: removeFirst(5)/getSize/toString #\n";
}
try {
btassert<bool>(list.removeFirst(30) == true && list.getSize() == 7 && list.toString() == "5,10,20,30,40,50,55");
cout << "Passed TEST 14: removeFirst(30)/getSize/toString \n";
} catch (bool b) {
cout << "# FAILED TEST 14: removeFirst(30)/getSize/toString #\n";
}
try {
btassert<bool>(list.removeFirst(30) == true && list.getSize() == 6 && list.toString() == "5,10,20,40,50,55");
cout << "Passed TEST 15: removeFirst(30)/getSize/toString \n";
} catch (bool b) {
cout << "# FAILED TEST 15: removeFirst(30)/getSize/toString #\n";
}
try {
btassert<bool>(list.removeFirst(55) == true && list.getSize() == 5 && list.toString() == "5,10,20,40,50");
cout << "Passed TEST 16: removeFirst(55)/getSize/toString \n";
} catch (bool b) {
cout << "# FAILED TEST 16: removeFirst(55)/getSize/toString #\n";
}
try {
btassert<bool>(list.removeFirst(10) == true && list.getSize() == 4 && list.toString() == "5,20,40,50");
cout << "Passed TEST 17: removeFirst(10)/getSize/toString \n";
} catch (bool b) {
cout << "# FAILED TEST 17: removeFirst(10)/getSize/toString #\n";
}
list.removeHead();
try {
btassert<bool>(list.getSize() == 3 && list.toString() == "20,40,50");
cout << "Passed TEST 18: removeHead/getSize/toString \n";
} catch (bool b) {
cout << "# FAILED TEST 18: removeHead/getSize/toString #\n";
}
list.removeTail();
try {
btassert<bool>(list.getSize() == 2 && list.toString() == "20,40");
cout << "Passed TEST 19: removeTail/getSize/toString \n";
} catch (bool b) {
cout << "# FAILED TEST 19: removeTail/getSize/toString #\n";
}
list.clear();
try {
btassert<bool>(list.getSize() == 0 && list.toString() == "");
cout << "Passed TEST 20: clear/getSize/toString \n";
} catch (bool b) {
cout << "# FAILED TEST 20: clear/getSize/toString #\n";
}
cout << "\nUNIT TEST COMPLETE\n\n";
}
示例8: setAnnotation
bool Annotate::setAnnotation(SCRef diff, SCRef author, SCList prevAnn, SList newAnn, int ofs)
{
newAnn.clear();
QStringList::const_iterator cur(prevAnn.constBegin());
QString line;
int idx = 0, num, lineNumStart, lineNumEnd;
int curLineNum = 1; // warning, starts from 1 instead of 0
bool inHeader = true;
while (getNextSection(diff, idx, line, "\n")) {
char firstChar = line.at(0).toLatin1();
if (inHeader) {
if (firstChar == '@')
inHeader = false;
else
continue;
}
switch (firstChar) {
case '@':
// an unified diff fragment header has form '@@ -a,b +c,d @@'
// where 'a' is old file line number and 'b' is old file
// number of lines of the hunk, 'c' and 'd' are the same
// for new file. If the file does not have enough lines
// then also the form '@@ -a +c @@' is used.
if (ofs == 0)
lineNumStart = line.indexOf('-') + 1;
else
// in this case we are given diff fragments with
// faked small files that span the fragment plus
// some padding. So we use 'c' instead of 'a' to
// find the beginning of our patch in the faked file,
// this value will be offsetted by ofs later
lineNumStart = line.indexOf('+') + 1;
lineNumEnd = line.indexOf(',', lineNumStart);
if (lineNumEnd == -1) // small file case
lineNumEnd = line.indexOf(' ', lineNumStart);
num = line.mid(lineNumStart, lineNumEnd - lineNumStart).toInt();
num -= ofs; // offset for range filter computation
// diff lines start from 1, 0 is empty file,
// instead QValueList::at() starts from 0
if (num < 0 || num > prevAnn.size()) {
dbp("ASSERT setAnnotation: start line number is %1", num);
isError = true;
return false;
}
for ( ; curLineNum < num; ++curLineNum) {
newAnn.append(*cur);
++cur;
}
break;
case '+':
newAnn.append(author);
break;
case '-':
if (curLineNum > prevAnn.size()) {
dbp("ASSERT setAnnotation: remove end of "
"file, diff is %1", diff);
isError = true;
return false;
} else {
++cur;
++curLineNum;
}
break;
case '\\':
// diff(1) produces a "\ No newline at end of file", but the
// message is locale dependent, so just test the space after '\'
if (line[1] == ' ')
break;
// fall through
default:
if (curLineNum > prevAnn.size()) {
dbp("ASSERT setAnnotation: end of "
"file reached, diff is %1", diff);
isError = true;
return false;
} else {
newAnn.append(*cur);
++cur;
++curLineNum;
}
break;
}
}
// copy the tail
for ( ; curLineNum <= prevAnn.size(); ++curLineNum) {
newAnn.append(*cur);
++cur;
}
return true;
}
示例9: unittest
//.........这里部分代码省略.........
cout << "# FAILED TEST 11: removeAll(1) #\n";
}
try {
btassert<bool>(intList.removeFirst(10) == true && intList.getSize() == 6 && intList.toString() == "5,10,15,30,30,50");
cout << "Passed TEST 12: removeFirst(10)/getSize/toString \n";
} catch (bool b) {
cout << "# FAILED TEST 12: removeFirst(10)/getSize/toString #\n";
}
try {
btassert<bool>(intList.removeAll(30) == true && intList.getSize() == 4 && intList.toString() == "5,10,15,50");
cout << "Passed TEST 13: removeAll(30)/getSize/toString \n";
} catch (bool b) {
cout << "# FAILED TEST 13: removeAll(30)/getSize/toString #\n";
}
intList.removeHead();
try {
btassert<bool>(intList.getSize() == 3 && intList.toString() == "10,15,50");
cout << "Passed TEST 14: removeHead/getSize/toString \n";
} catch (bool b) {
cout << "# FAILED TEST 14: removeHead/getSize/toString #\n";
}
intList.removeTail();
try {
btassert<bool>(intList.getSize() == 2 && intList.toString() == "10,15");
cout << "Passed TEST 15: removeTail/getSize/toString \n";
} catch (bool b) {
cout << "# FAILED TEST 15: removeTail/getSize/toString #\n";
}
intList.clear();
try {
btassert<bool>(intList.getSize() == 0 && intList.toString() == "");
cout << "Passed TEST 16: clear/getSize/toString \n";
} catch (bool b) {
cout << "# FAILED TEST 16: clear/getSize/toString #\n";
}
cout << "\nSTRING LIST TEST\n\n";
SList<string> stringList;
try {
btassert<bool>(stringList.getSize() == 0);
cout << "Passed TEST 17: default constructor (size) \n";
} catch (bool b) {
cout << "# FAILED TEST 17: default constructor (size) #\n";
}
try {
btassert<bool>(stringList.toString() == "");
cout << "Passed TEST 18: toString \n";
} catch (bool b) {
cout << "# FAILED TEST 18: toString #\n";
}
stringList.insert("hello");
try {
btassert<bool>(stringList.getSize() == 1 && stringList.toString() == "hello");
cout << "Passed TEST 19: insert(\"hello\")/getSize/toString \n";
} catch (bool b) {
cout << "# FAILED TEST 19: insert(\"hello\")/getSize/toString #\n";
}