Changeset 5100 in orxonox.OLD for trunk/src/lib/util
- Timestamp:
- Aug 22, 2005, 12:42:28 PM (19 years ago)
- File:
-
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/lib/util/array.h
r5097 r5100 16 16 /*! 17 17 \file array.h 18 \brief Contains the Array Class that handles float arrays.18 \brief Contains the Array Class that handles arrays of classes. 19 19 this class creates a Array of a semi-Dynamic length. 20 20 beware, that after finalizing the array may not be resized again. … … 25 25 #include "debug.h" 26 26 27 //! Array Class that handles dynamic- floatarrays.27 //! Array Class that handles dynamic-type arrays. 28 28 template<class T> class Array 29 29 { … … 38 38 /** @returns The array */ 39 39 inline const T* getArray () const { return this->array; }; 40 inline const T getEntry(unsigned int number) const; 40 41 /** * @returns The Count of entries in the Array*/ 41 42 inline unsigned int getCount()const { return this->entryCount; }; … … 66 67 Array<T>::Array () 67 68 { 68 PRINTF( 4)("crating new Array\n");69 PRINTF(5)("crating new Array\n"); 69 70 this->firstEntry = new Entry; 70 71 this->firstEntry->next =NULL; … … 72 73 this->finalized = false; 73 74 this->entryCount = 0; //0 means one entry 75 } 76 77 template<class T> 78 const T Array<T>::getEntry(unsigned int number) const 79 { 80 if (this->finalized && number < this->entryCount) 81 return this->array[number]; 74 82 } 75 83 … … 81 89 Array<T>::~Array() 82 90 { 83 PRINTF( 4)("deleting array\n");91 PRINTF(5)("deleting array\n"); 84 92 Entry* walker = this->firstEntry; 85 93 Entry* previous; … … 91 99 } 92 100 if (finalized) 93 delete []this->array;101 delete[] this->array; 94 102 } 95 103 … … 101 109 void Array<T>::finalizeArray () 102 110 { 103 PRINTF(4)("Finalizing array. Length: %i\n", entryCount); 104 // if ((array = (GLfloat*)malloc( entryCount* sizeof(GLfloat))) == NULL) 105 if (!(this->array = new GLfloat [this->entryCount])) 106 PRINTF(0)("could not allocate %i data Blocks\n", this->entryCount); 111 PRINTF(5)("Finalizing array. Length: %i\n", entryCount); 112 if (!(this->array = new T [this->entryCount])) 113 PRINTF(1)("could not allocate %i data Blocks\n", this->entryCount); 107 114 Entry* walker = this->firstEntry; 108 115 for (int i=0; i<this->entryCount; i++)
Note: See TracChangeset
for help on using the changeset viewer.