⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 wzarray.hxx

📁 Delaunay三角形的网格剖分程序
💻 HXX
字号:
#ifndef WZARRAY_HXX#define WZARRAY_HXX#include "wz.hxx"// defines the template class wzArray<>class wzAllocationStrategy;class wzMultipleArrayController;class wzMemoryAllocation;class wzArrayBody;class wzRange; // because the g++ compiler cannot solve things correctly.class wzMemoryAllocation{public:        wzBoolean allocate(wzByte*& base,		wzIndex& num, wzIndex min=0, wzIndex fac=1);};class wzArrayRangeError: public wzError{public:  wzInteger actual;  wzIndex   max;  wzArrayRangeError(wzInteger a, wzIndex m)    :wzError("wzarraytest","RangeError"),actual(a),max(m){;}};class wzArrayBody: private wzMemoryAllocation{protected:friend class wzMultipleArrayController;	wzByte*	Base;	wzIndex	Shift;	wzIndex Max;	wzMultipleArrayController* From;	wzIndex Index;        void*   address(wzIndex i=0)	const{#ifdef wzDebug if(i>=Max) {throw wzArrayRangeError(i,Max);}#endif return  (void*)(Base+i*Shift);}        wzBoolean Allocate(wzIndex i){return allocate(Base,Max,i,Shift);}	wzBoolean require(wzIndex i);	void reinitialize(wzMultipleArrayController&,			wzIndex size, wzIndex max=0);	void reinitialize(const wzMultipleArrayController&,			wzIndex size, wzIndex max=0);	void reinitialize(wzArrayBody& a, wzIndex off=0);	void reinitialize();	wzArrayBody(wzAddress r)		:Base((wzByte*)r),Max(0),Shift(0),From(0),Index(0){;}	wzArrayBody(wzIndex size=1, wzIndex max=0)		:Base(0),Max(0),Shift(size),From(0),Index(0)		{if(max) Allocate(max);}	wzArrayBody(wzMultipleArrayController&, 			wzIndex size, wzIndex max=0);	wzArrayBody(const wzMultipleArrayController&,			wzIndex size, wzIndex max=0);	wzArrayBody(wzArrayBody& a, wzIndex off=0);	~wzArrayBody();};template<class T> class wzArray: public wzArrayBody{public:// different array types:  wzArray(T& t)    :wzArrayBody((wzAddress)&t){;}  wzArray(wzIndex multiple=1, wzIndex max=0)    :wzArrayBody(multiple*sizeof(T),max) {;}  wzArray(wzArray<T>& a, wzIndex off=0)    :wzArrayBody(a,off*sizeof(T)){;}  wzArray(wzArrayBody& a, wzIndex off=0, wzIndex size=sizeof(wzByte))    :wzArrayBody(a,off*size){;}  wzArray(wzMultipleArrayController& c, wzIndex mult=1, wzIndex max=0)    :wzArrayBody(c,mult*sizeof(T),max) {;}  wzArray(const wzMultipleArrayController& c, wzIndex mult=1,wzIndex max=0)    :wzArrayBody(c,mult*sizeof(T),max) {;}  wzArray(wzRange& r, wzIndex mult=1, wzIndex max=0)    :wzArrayBody(*(wzMultipleArrayController*)&r, mult*sizeof(T),max) {;}  wzArray(const wzRange& r, wzIndex mult=1, wzIndex max=0)    :wzArrayBody(*(wzMultipleArrayController const*)&r, mult*sizeof(T),max) {;}  void reinitialize(wzMultipleArrayController& c, wzIndex mult=1,wzIndex max=0)  {wzArrayBody::reinitialize(c,mult*sizeof(T),max);}  void reinitialize(const wzMultipleArrayController& c, wzIndex mult=1,wzIndex max=0)  {wzArrayBody::reinitialize(c,mult*sizeof(T),max);}  void reinitialize(wzArrayBody& a, wzIndex off=0)  {wzArrayBody::reinitialize(a,off);}  void reinitialize(wzArray<T>& a, wzIndex off=0)  {wzArrayBody::reinitialize(a,sizeof(T)*off);}  void reinitialize();  // fast access:  T  operator*()                      {return v();}  T& operator*()                const {return v();}  const T& operator[](wzIndex i)const {return v(i);}  T& operator[](wzIndex i)            {return v(i);}  T* operator+(wzIndex i)       const {return (T*)address(i);}  // controlled access (allocation if required) - only for separate arrays  T& operator()(wzIndex i)  {if(i>=Max) require(i); return v(i);}  wzBoolean available(wzIndex i)  {if(i<Max)return wzTrue; return require(i);}  wzIndex allocated()	const {return Max;}private:  wzArray<T>&    operator=(const wzArray<T>&);  T& v(wzIndex i=0)   const {return *(T*)address(i);}};class wzMultipleArrayController{private:	   static const   wzIndex TypeUndefined;	   static const   wzIndex TypeSeparate;	   static const   wzIndex TypeComponent;	   wzIndex        Last;	   wzIndex        Free;	   wzArray<wzIndex> Type;	   wzArray<wzIndex> Base;	   wzArray<wzIndex> Offset;           wzArray<wzArrayBody*> Field;protected:friend class wzArrayBody;           wzIndex  defineArray    (wzArrayBody *f);	   wzIndex  defineComponent(wzArrayBody *f,wzIndex base,wzIndex off);	   void     destroyArray(wzIndex field);	   wzBoolean      Allocate(wzIndex i);	   wzIndex        Max;public:	   wzBoolean available(wzIndex i)		{if(i<Max) return wzTrue; return Allocate(i);}	   void require(wzIndex i)		{if(i>=Max) if(!Allocate(i+1)) {throw wzNotEnoughMemory();}}	   void free()		{Allocate(0);}	   wzMultipleArrayController(wzIndex ini=0);	   ~wzMultipleArrayController();};class wzArrayStaticInitializationManager{	static wzIndex count;protected:friend class wzMemoryAllocation;        static wzIndex AllocationCount;public:	wzArrayStaticInitializationManager();	~wzArrayStaticInitializationManager();};static wzArrayStaticInitializationManager wzArrayStaticInitializationManager_;#endif

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -