本文整理汇总了C++中DLNode::GetContents方法的典型用法代码示例。如果您正苦于以下问题:C++ DLNode::GetContents方法的具体用法?C++ DLNode::GetContents怎么用?C++ DLNode::GetContents使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DLNode
的用法示例。
在下文中一共展示了DLNode::GetContents方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: RemoveFirst
void DLList::RemoveFirst(int value){
DLNode* temp = head;
bool found = false;
while((temp != NULL) && (!found)) {
if (temp->GetContents() == value) {
if (temp->GetNext() != NULL) {
temp->GetNext()->SetPrevious(temp->GetPrevious());
}
if (temp->GetPrevious() != NULL) {
temp->GetPrevious()->SetNext(temp->GetNext());
}
if (temp == head){
head = temp->GetNext();
} else if (temp == tail) {
tail = temp->GetPrevious();
}
delete temp;
temp = NULL;
size--;
found = true;
}
if(temp != NULL) {
temp = temp->GetNext();
}
}
if (!found) {
cerr << "Not Found" << endl;
}
}
示例2: Exists
bool DLList::Exists(int value){
DLNode* temp = head;
while (temp != NULL) {
if (temp->GetContents() == value) {
return true;
}
temp = temp->GetNext();
}
return false;
}
示例3: ToStringBackwards
string DLList::ToStringBackwards(){
if (head == NULL){
cerr << "List Empty" << endl;
return "";
}
stringstream ss;
DLNode* temp = tail;
while(temp != NULL) {
ss << temp->GetContents();
if (temp != head){
ss << ", ";
}
temp = temp->GetPrevious();
}
return ss.str();
}
示例4: ToStringForwards
string DLList::ToStringForwards(){
if (head == NULL){
cerr << "List Empty" << endl;
return "";
}
stringstream ss;
DLNode* temp = head;
while(temp != NULL) {
ss << temp->GetContents();
if (temp != tail){
ss << ", ";
}
temp = temp->GetNext();
}
return ss.str();
}