00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #ifndef __LIST_H_
00019 #define __LIST_H_
00020
00021
00022 #include "Utilities.h"
00023
00025 template <typename Type> class List
00026 {
00027 public:
00028
00030 List(int size)
00031 {
00032
00033 listData = NULL;
00034 listSize = 0;
00035
00036
00037 Resize(size);
00038 }
00039
00041 ~List()
00042 {
00043
00044 if(listData != NULL)
00045 delete[] listData;
00046 }
00047
00049 Type& operator[](int index)
00050 {
00051
00052 Assert(listSize > 0, "Empty data set memory access.");
00053
00054
00055 Assert(index >= 0 && index < listSize, "Out of bounds memory access.");
00056
00057
00058 return listData[index];
00059 }
00060
00062 void Resize(int newSize)
00063 {
00064
00065 if(newSize <= 0)
00066 {
00067 listSize = 0;
00068 if(listData != NULL)
00069 delete[] listData;
00070 listData = NULL;
00071 }
00072 else
00073 {
00074
00075 Type *newData = new Type[newSize];
00076
00077
00078
00079
00080
00081 if(listData != NULL)
00082 delete[] listData;
00083
00084
00085 listData = newData;
00086 listSize = newSize;
00087 }
00088 }
00089
00091 int GetSize()
00092 {
00093 return listSize;
00094 }
00095
00096 private:
00097
00098 Type *listData;
00099 int listSize;
00100 };
00101
00102 #endif