⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 itemlist.cpp

📁 一个在linux下的shell的计算器
💻 CPP
字号:
/* * * * */#include <iostream>#include <sstream>#include "itemlist.h"#include "exception.h"using namespace std;//////ItemList::ItemList(): Item(){ type = LIST; first = last = NULL;}//////ItemList::~ItemList(){ Clear();}//////void ItemList::Clear(){ Item *p = first, *q=NULL; while (p != NULL) {  q = p->next;  delete p;  p = q; } first = last = NULL;}//////void ItemList::Add(Item *p){ if (last == NULL) first = last = p; else  {  last->next = p;  p->prev = last;  last = last->next;  }}//////Item *ItemList::First(){ return first;}//////Item *ItemList::Last(){ return last;}//////void ItemList::Remove(Item *p){ Item *iprev = p->prev; Item *inext = p->next; if (iprev != NULL) iprev->next = inext; else first = inext; if (inext != NULL) inext->prev = iprev; else last = iprev; if (first != NULL) first->prev = NULL; if (last != NULL) last->next = NULL;}//////int ItemList::Length(){ Item *p; int c = 0; for (p=last;p!=NULL;p=p->prev) c++; return c;}//////Item *ItemList::Clone(){ Item *p; ItemList *l = new ItemList(); for (p=first;p!=NULL;p=p->next) l->Add(p->Clone()); return l;}//////string ItemList::ToString() const{ Item *p; ostringstream str; str << "{"; for (p=first;p!=NULL;p=p->next)   str << " " << p->ToString();  str << " }"; return str.str();}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -