发布时间: 2012-07-31 12:33:46 作者: rapoo
list实现#ifndef LIST_H#define LIST_H#include <cassert>template<typename T>struct Iterator{ T t; Iterator *next;};template<typename T>class list_t{ Iterator<T> *_start,*_end; typedef unsigned int size_t; size_t _count;public: list_t():_start(0), _end(0), _count(0) { } ~list_t() { Clear(); } void Clear() { if(_count>0) { Iterator<T> *pT=_start; while(pT) { Iterator<T> *pNext=pT->next; delete pT; pT=pNext; } _start=0; _end=0; _count=0; } } bool Insert(T &t) { Iterator<T> *pT=new Iterator<T>; assert(pT); pT->t=t; pT->next=NULL; if(!_start) { _start=pT; _end=pT; } else { _end->next=pT; _end=pT; } ++_count; return true; } bool Delete(T &t) { Iterator<T> *pT=_start; Iterator<T> *pFront=NULL; while(pT) { if(pT->t==t) { if(pT==_start) { _start=pT->next; } else { if(pT==_end) _end=pFront; pFront->next=pT->next; } --_count; delete pT; return true; } pFront=pT; pT=pT->next; } return false; } Iterator<T>* find(T &t) { Iterator<T> *pT=_start; while(pT) { if(pT->t==t) break; pT=pT->next; } return pT; } Iterator<T>* begin()const { return _start; } Iterator<T>* end()const { return NULL; } size_t Count()const { return _count; }};#endif
JAVA基础-java中ET的差异
ByteBuffer跟String的互相转换
vim 编辑器的三种模式怎么切换
电脑编码
地图reduce编程模型介绍
Java基础java缓存读写资料小例子
学习jar下令 创建和解压jar文件包
java生成随机数、四舍五入、当前时间的
[猖獗Java讲义精粹] 第十一章|多线程
Java Thread 小结