红藕香残玉簟春 红藕香残玉簟春
关注数: 35 粉丝数: 79 发帖数: 2,201 关注贴吧数: 18
请问这个顺序表怎么实现? #ifndef ARRAY_H_INCLUDED #define ARRAY_H_INCLUDED #include<iostream> #include<list> using namespace std; template <class Elem> class AList:public List<Elem> { private: int maxSize;//数组最大的存储量 int listSize;//数组实际的存储量 int fence;//栅栏 Elem* listArray;// public: AList(int size = DefaultListSize)//构造函数 { maxSize = size; listSize = fence = 0; ListArray = new Elem[maxSize]; } ~Alist()//析构函数 { delete [] listArray; } void clear() { delete [] listArray; listSize = fence = 0; listArray = new Elem[maxSoze]; } bool insert(const Elem&); bool append(const Elem&); bool remove(Elem&); void setStart() { fence = 0; } void setEnd() { fence = listSize; } void prev() { if(fence!=0) fence--; } void next() { if(fence<=listSize) { fence++; } } int leftLength() const { return fence; } int rightLength() const { return listSize - fence; } bool setPos(int pos) { if((pos>=0)&&(pos<=listSize)) fence = pos; return (pos>=0)&&(pos<=listSize); } bool getValue(Elem& it) const { if(rightLength()==0) return false; else { it = listArray[fence]; return true; } } void print() const { int temp = 0; cout<<"<"; while(temp <fence) cout<<listArray[temp++] <<" "; cout<<" "; while(temp<listSize) cout<<listArray[temp++] <<" "; cout<<">\n"; } }; template <class Elem> bool AList::insert(const Elem& item) { if(listSize == maxSize) return false; for(i = listSize;i>fence;i--) { listArray[i] = listArray[i-1]; listArray[fence] = item; listSize++; return true; } } template <class Elem> bool Alist::append(const Elem& item) { if(listSize==maxSize) return false; listArray[listSize++] = item; return true; } template <class Elem> bool AList<Elem>::remove(Elem& it) { if(rightLength()==0) return false; it = listArray[fence]; for(int i = fence;i<listSize-1;i++) { listArray[i] = listArray[i+1]; } listSize--; return true; } #endif // ARRAY_H_INCLUDED
转贴:使用Eclipse调试Java程序的10个技巧(1) 你应该看过一些如《关于调试的N件事》这类很流行的帖子 .假设我每天花费1小时在调试我的应用程序上的话,那累积起来的话也是很大量的时间.由于这个原因,用这些时间来重视并了解所有使我们调试更方便的功能.那能为你省下一些时间,也将会使你的生活更安逸,轻松.同时也表明其它关于此主题的帖子也是很有价值的.第1条:不要调试太多一个关于调试的疯狂声明作为开头.但它必须是要说的!尝试切分一下你那复杂的逻辑成多个独立的单元,并编写单元测试来检测你代码的正确性.我想像如下这样的流程应该是发生得非常频繁的----一些人通过大型web应用程序点击,填写多个表单,切换到不同的页面,正在最后的页面上检测工个计算逻辑和实现这个调试视图中的大部分逻辑.在启动你的tomcat之前总是问你自己:有没有方法使用一个单元测试来检测这些行为?你在过去这些时间可以不知道或已忘记这些,但从现在开始,我们将要关注一些eclipse的调试技巧,你会发现有大量的关于良好代码设计的好东西.- 断点视图 : 条件断点如果你只对应用中的某部分感兴趣的话,这个功能非常有用.例如,如果你要在第13次循环的时候检查程序,或者在一个抽象父类中调试某些功能,而你只关注其中一个具体的实现.你可以在断点视图中设置条件,或者通过代码旁边的蓝色断点标记的右键菜单("Breakpoint Properties")设置.你可以在条件代码片段为true的时候暂停程序,或者当代码片段的值改变的时候挂起程序. 假设我每天花费1小时在调试我的应用程序上的话,那累积起来的话也是很大量的时间.由于这个原因,用这些时间来重视并了解所有使我们调试更方便的功能.转自:http://tieba.baidu.com/mo/q/checkurl?url=http%3A%2F%2Fdeveloper.51cto.com%2Fart%2F201304%2F388155.htm%23585532-tieba-1-75388-b59f551281c5c9edca46440323d0c198&urlrefer=5e7fab814cefab8ff593fb28e004767c
1 下一页