本文整理汇总了C++中DLList::removeHead方法的典型用法代码示例。如果您正苦于以下问题:C++ DLList::removeHead方法的具体用法?C++ DLList::removeHead怎么用?C++ DLList::removeHead使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DLList
的用法示例。
在下文中一共展示了DLList::removeHead方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: processFile
void processFile (string filename) {
stringstream ss;
int value = 0;
DLList* list = NULL;
char firstCharacter;
ifstream fin(filename.c_str());
if(!fin.fail()) {
string nextline;
while(!fin.eof()) {
getline(fin, nextline);
firstCharacter = nextline[0];
switch(firstCharacter) {
case '#':
break;
case 'C':
if(list != NULL) { //if there was a previous list delete it
delete list;
}
else {
//creates a new list of type DLList
list = new DLList();
cout << "LIST CREATED" << endl;
}
break;
case 'X':
//if no list was created yet create list first
if(list == NULL) {
cout << "MUST CREAT LIST INSTANCE" << endl;
} //if there was a list clear it with the clear function
else {
list->clear();
cout << "LIST CLEARED" << endl;
}
break;
case 'D':
//if there is a list deleted it
if(list!= NULL) {
delete list;
cout << "LIST DELETED" << endl;
}//if there isn't show warning
else
cout << "MUST CREAT LIST INSTANCE" << endl;
break;
case 'I':
if(list == NULL) {
cout << "MUST CREAT LIST INSTANCE" << endl;
}
else {
ss.str(nextline.substr(2));//gets the next whole value after the first value on a line
ss >> value;//puts the from input into an int
list->insert(value);//inserts the value into a node on the list
cout << "VALUE " << value << " INSERTED" << endl;
ss.clear();
ss.str("");
}
break;
case 'F':
ss.str(nextline.substr(2));
ss >> value;
list->insertHead(value);//inserts the value from input into the first node
cout << "VALUE " << value << " ADDED TO HEAD" << endl;
ss.clear();
ss.str("");
break;
case 'B':
ss.str(nextline.substr(2));
ss >> value;
list->insertTail(value);
cout << "VALUE " << value << " ADDED TO TAIL" << endl;
ss.clear();
ss.str("");
break;
case 'A':
if(list == NULL) {
cout << "VALUE NULL AT HEAD" << endl;
}
else {
list->getHead();
cout << "VALUE " << list->getHead() << " AT HEAD" << endl;
}
break;
case 'Z':
list->getTail();
cout << "VALUE " << list->getTail() << " AT TAIL" << endl;
break;
case 'T':
if(list == NULL) {
cout << "MUST CREATE LIST INSTANCE" << endl;
}
else if (list->getSize() > 0) {
list->removeHead();
cout << "REMOVED HEAD" << endl;
}
else {
cout << "LIST EMPTY" << endl;
}
break;
case 'K':
if(list == NULL) {
//.........这里部分代码省略.........