Main Page | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | Related Pages

container.h

00001 /* 00002 * =========================== 00003 * VDK Visual Develeopment Kit 00004 * Version 0.4 00005 * October 1998 00006 * =========================== 00007 * 00008 * Copyright (C) 1998, Mario Motta 00009 * Developed by Mario Motta <mmotta@guest.net> 00010 * 00011 * This library is free software; you can redistribute it and/or 00012 * modify it under the terms of the GNU Library General Public 00013 * License as published by the Free Software Foundation; either 00014 * version 2 of the License, or (at your option) any later version. 00015 * 00016 * This library is distributed in the hope that it will be useful, 00017 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00018 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00019 * Library General Public License for more details. 00020 * 00021 * You should have received a copy of the GNU Library General Public 00022 * License along with this library; if not, write to the Free Software 00023 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 00024 * 02111-1307, USA. 00025 */ 00026 00027 #ifndef CONTAINER_H 00028 #define CONTAINER_H 00029 /******************* 00030 * Class VDKContainer * 00031 *******************/ 00036 template <class T> 00037 class VDKContainer 00038 { 00039 protected: 00040 T* data; 00041 int count; 00042 public: 00047 VDKContainer(int count=0): 00048 data(count > 0 ? new T[count]: 0), 00049 count(count) 00050 { 00051 } 00052 00053 virtual ~VDKContainer() 00054 { 00055 if (data) 00056 delete[] data; 00057 } 00061 T& operator[](int n) 00062 { 00063 return data[n]; 00064 } 00068 int size(){return count;} 00072 VDKContainer(const VDKContainer<T>& c); 00076 VDKContainer<T>& operator=(const VDKContainer<T>& c); 00080 int operator ==(const VDKContainer<T>& c); 00081 00082 }; 00083 00084 00085 template <class T> 00086 VDKContainer<T>::VDKContainer(const VDKContainer<T>& c) 00087 { 00088 data=0; 00089 *this=c; 00090 } 00091 00092 00093 template <class T> 00094 VDKContainer<T>& VDKContainer<T>::operator=(const VDKContainer<T>& c) 00095 { 00096 if (this!= &c) 00097 { 00098 if(data)delete[]data; 00099 count=c.count; 00100 data= count >0 ?new T[count]:0; 00101 for (int i=0;i<count;i++) 00102 data[i]=c.data[i]; 00103 } 00104 return *this; 00105 } 00106 00107 00108 template <class T> 00109 int VDKContainer<T>::operator ==(const VDKContainer<T>& c) 00110 { 00111 int i=0; 00112 if(count!=c.count)return 0; 00113 for (;(i<count) && (data[i]==c.data[i]);i++); 00114 return i==count ?1:0; 00115 } 00116 00117 #endif 00118 00119 00120

Generated on Tue Aug 17 12:39:50 2004 for vdk 2.4.0 by doxygen 1.3.7