00001 /* *********************************************************************************** 00002 Writer: Sebastien Bloc 00003 Copyright: 2003-2004 00004 eMail: sebastien.bloc@free.fr 00005 URL: http://mignonsoft.free.fr 00006 00007 This program is free software; you can redistribute it and/or 00008 modify it under the terms of the GNU General Public License 00009 as published by the Free Software Foundation; either version 2 00010 of the License, or (at your option) any later version. 00011 00012 This program is distributed in the hope that it will be useful, 00013 but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00015 GNU General Public License for more details. 00016 http://www.gnu.org/copyleft/gpl.html 00017 *********************************************************************************** */ 00018 00034 #ifndef INCLUDE_ARRAY_H 00035 #define INCLUDE_ARRAY_H 00036 00037 #include <stdio.h> 00038 #include <windows.h> 00039 00040 template <class T> 00041 class Array 00042 { 00043 public: 00044 int size; 00045 T *values; 00046 00047 Array() 00048 { 00049 } 00050 00051 Array(int _size) 00052 { 00053 Init(_size); 00054 } 00055 00056 ~Array() 00057 { 00058 Delete(); 00059 } 00060 00061 void operator = (Array &src) 00062 { 00063 size=src.size; 00064 } 00065 00066 void Init(int _size) 00067 { 00068 size=_size; 00069 values=NULL; 00070 } 00071 00072 void New() 00073 { 00074 Delete(); 00075 values = new T[size]; 00076 Zero(); 00077 } 00078 00079 void Zero() 00080 { 00081 operator=(0); 00082 } 00083 00085 void operator=(int val) 00086 { 00087 for (int i=0;i<size;i++) values[i]=0; 00088 } 00089 00090 void Delete() 00091 { 00092 if (values) 00093 { 00094 delete values; 00095 Init(size); 00096 } 00097 } 00098 00099 BOOL Set(int num,T value) 00100 { 00101 if (!values||num>=size) return FALSE; 00102 values[num]=value; 00103 return TRUE; 00104 } 00105 }; 00106 00107 #endif