ESyS-Particle
4.0.1
|
00001 00002 // // 00003 // Copyright (c) 2003-2011 by The University of Queensland // 00004 // Earth Systems Science Computational Centre (ESSCC) // 00005 // http://www.uq.edu.au/esscc // 00006 // // 00007 // Primary Business: Brisbane, Queensland, Australia // 00008 // Licensed under the Open Software License version 3.0 // 00009 // http://www.opensource.org/licenses/osl-3.0.php // 00010 // // 00012 00013 #ifndef _T_LIST_H_ 00014 #define _T_LIST_H_ 00015 #include <string.h> 00016 #ifndef NULL 00017 #define NULL 0 00018 #endif 00019 00020 #ifdef _LINUX 00021 #include <stddef.h> 00022 #endif 00023 00024 #ifdef _DEBUG 00025 #include "console.h" 00026 #endif 00027 00028 template<class T> 00029 class Node 00030 { 00031 public: 00032 Node<T> *Next, *Prev ; 00033 T *Val ; 00034 } ; 00035 00039 template <class T> 00040 class List 00041 { 00042 protected: 00043 Node<T> *Start ; 00044 Node<T> *End; 00045 Node<T> *Current ; 00046 public: 00047 inline List() ; 00048 inline List(const List &L) ; 00049 virtual ~List() ; 00050 00051 inline void Swap() ; 00052 inline void InsertAtStart(T *V) ; 00053 inline void Append(T *V) ; 00054 inline void InsertAfter(T *V) ; 00055 inline void InsertBefore(T *V) ; 00056 inline T* Get() ; 00057 inline void Put(T *V) ; 00058 00059 inline void Clear() ; 00060 inline void Destroy() ; 00061 00062 inline List& operator << (T *V) ; 00063 inline List& operator >> (T *V) ; 00064 00065 inline void Next() ; 00066 inline void Prev() ; 00067 inline void First() ; 00068 inline void Last() ; 00069 00070 inline int IsEnd() ; 00071 inline int IsStart() ; 00072 00073 inline int SizeList() ; 00074 00075 inline List operator + (const List& L) ; 00076 inline List& operator += (const List& L) ; 00077 inline List& operator = (const List& L) ; 00078 } ; 00079 00080 00084 template< class T> 00085 class Stack { 00086 protected: 00087 List<T> L ; 00088 public: 00089 inline Stack() {} ; 00090 virtual ~Stack() { L.Destroy() ; } ; 00091 00092 inline void Push(T* V) ; 00093 00094 inline T* Pop() ; 00095 } ; 00096 00097 #if 0 00098 00102 template <class T> 00103 class ListWS: public List<T> { 00104 protected: 00105 Stack<Node<T> > stack ; 00106 public: 00107 inline ListWS() : List<T>() {} ; 00108 inline ListWS(const ListWS &L) : List<T>(L) { } ; 00109 virtual ~ListWS() { } ; 00110 00111 inline void PushPos() ; 00112 inline void PopPos() ; 00113 } ; 00114 #endif 00115 #include "t_list.hpp" 00116 00117 #endif 00118