Main Page | Class Hierarchy | Class List | File List | Class Members

barray.h

00001 /*============================================================================= 00002 File: barray.h 00003 Purpose: 00004 Revision: $Id: barray.h,v 1.3 2002/05/24 17:08:34 philosophil Exp $ 00005 Created by: Philippe Lavoie (3 Oct, 1996) 00006 Modified by: 00007 00008 Copyright notice: 00009 Copyright (C) 1996-1998 Philippe Lavoie 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 00023 Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 00024 =============================================================================*/ 00025 00026 #ifndef _MATRIX_barray_h_ 00027 #define _MATRIX_barray_h_ 00028 00029 #include "matrix_global.h" 00030 #include "specialType.h" 00031 #include "list.h" 00032 00033 // Predefining every friend functions 00034 // This is required by the latest ISO C++ draft 00035 00038 namespace PLib { 00039 template <class T> class BasicArray ; 00040 00041 template <class T> int operator!=(const BasicArray<T>&,const BasicArray<T>&); 00042 template <class T> int operator==(const BasicArray<T>&,const BasicArray<T>&); 00043 template <class T> istream& operator>>(istream& is, BasicArray<T>& arry); 00044 template <class T> ostream& operator<<(ostream& os, const BasicArray<T>& arry); 00045 00046 #include "galloc.h" 00047 00048 00058 template<class T> class BasicArray 00059 { 00060 public: 00061 int n() const 00062 { return sze; } 00063 BasicArray(); 00064 BasicArray(const int ni); 00065 BasicArray(const BasicArray<T>& f2); 00066 BasicArray(T* ap, const int size) ; 00067 BasicArray(BasicList<T>& list) ; 00068 virtual ~BasicArray(); 00069 00070 BasicArray<T>& operator=(const BasicArray<T>& f2); 00071 00072 int size() const 00073 { return sze; } 00074 void resize(const int nsize) 00075 { resizeBasicArray(*this,nsize) ; } 00076 void resize(const BasicArray<T>& A) 00077 { resize(A.n()); } 00078 00079 void trim(const int nsize); 00080 void clear(); 00081 void untrim() 00082 { sze = rsize; } 00083 00084 T& push_back(const T i, int end_buffer=10, double end_mult=-1); 00085 00086 00087 virtual void reset(const T val = 0.0); 00088 T operator=(const T val) 00089 { reset(val); return val; } 00090 00091 #ifdef DEBUG_PLIB 00092 T& operator[](const int i) ; 00093 T operator[](const int i) const ; 00094 #else 00095 T& operator[](const int i) 00096 { return x[i]; } 00097 T operator[](const int i) const 00098 { return x[i]; } 00099 #endif 00100 T* memory() const 00101 { return x ; } 00102 00103 void width(const int w) 00104 { wdth = w; } 00105 00106 #ifdef HAVE_ISO_FRIEND_DECL 00107 friend int operator!= <>(const BasicArray<T>&,const BasicArray<T>&); 00108 friend int operator== <>(const BasicArray<T>&,const BasicArray<T>&); 00109 friend istream& operator>> <>(istream& is, BasicArray<T>& arry); 00110 friend ostream& operator<< <>(ostream& os, const BasicArray<T>& arry); 00111 #else 00112 friend int operator!= (const BasicArray<T>&,const BasicArray<T>&); 00113 friend int operator== (const BasicArray<T>&,const BasicArray<T>&); 00114 friend istream& operator>> (istream& is, BasicArray<T>& arry); 00115 friend ostream& operator<< (ostream& os, const BasicArray<T>& arry); 00116 #endif 00117 00118 ostream& print(ostream& os) const ; 00119 00120 FRIEND_ARRAY_ALLOCATOR 00121 00122 // compatibility for std:vector 00123 typedef T* iterator ; 00124 typedef const T* const_iterator ; 00125 00126 iterator begin() { return (0<sze) ? x : 0 ; } 00127 const_iterator begin() const { return (0<sze) ? x : 0 ; } 00128 00129 iterator end() { return (0<sze) ? x+sze : 0; } 00130 const_iterator end() const { return (0<sze) ? x+sze : 0; } 00131 00132 protected: 00133 int rsize; 00134 int wdth; 00135 int destruct ; 00136 int sze; 00137 T *x; 00138 }; 00139 00140 } // end namespace 00141 00142 typedef PLib::BasicArray<int> BasicArray_INT ; 00143 typedef PLib::BasicArray<char> BasicArray_BYTE ; 00144 typedef PLib::BasicArray<double> BasicArray_DOUBLE ; 00145 typedef PLib::BasicArray<float> BasicArray_FLOAT ; 00146 typedef PLib::BasicArray<Complex> BasicArray_COMPLEX ; 00147 typedef PLib::BasicArray<unsigned char> BasicArray_UBYTE ; 00148 typedef PLib::BasicArray<PLib::HPoint3Df> BasicArray_HPoint3D ; 00149 typedef PLib::BasicArray<PLib::Point3Df> BasicArray_Point3D ; 00150 typedef PLib::BasicArray<PLib::HPoint3Dd> BasicArray_HPoint3Dd ; 00151 typedef PLib::BasicArray<PLib::Point3Dd> BasicArray_Point3Dd ; 00152 typedef PLib::BasicArray<PLib::HPoint2Df> BasicArray_HPoint2D ; 00153 typedef PLib::BasicArray<PLib::Point2Df> BasicArray_Point2D ; 00154 typedef PLib::BasicArray<PLib::HPoint2Dd> BasicArray_HPoint2Dd ; 00155 typedef PLib::BasicArray<PLib::Point2Dd> BasicArray_Point2Dd ; 00156 typedef PLib::BasicArray<void*> BasicArray_VoidPtr ; 00157 typedef PLib::BasicArray<PLib::Coordinate> BasicArray_Coordinate ; 00158 00159 #ifdef INCLUDE_TEMPLATE_SOURCE 00160 #include "barray.cpp" 00161 #include "barray_hpoint.cpp" 00162 #endif 00163 00164 00165 00166 #endif

Generated on Wed Aug 18 07:07:37 2004 for NURBS++ by doxygen 1.3.7