Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 5100 in orxonox.OLD for trunk/src/lib/util/array.h


Ignore:
Timestamp:
Aug 22, 2005, 12:42:28 PM (19 years ago)
Author:
bensch
Message:

orxonox/trunk: testing some AutoCompletion in the Shell.

File:
1 moved

Legend:

Unmodified
Added
Removed
  • trunk/src/lib/util/array.h

    r5097 r5100  
    1616/*!
    1717  \file array.h
    18   \brief Contains the Array Class that handles float arrays.
     18  \brief Contains the Array Class that handles arrays of classes.
    1919  this class creates a Array of a semi-Dynamic length.
    2020  beware, that after finalizing the array may not be resized again.
     
    2525#include "debug.h"
    2626
    27 //! Array Class that handles dynamic-float arrays.
     27//! Array Class that handles dynamic-type arrays.
    2828template<class T> class Array
    2929{
     
    3838    /** @returns The array */
    3939    inline const T* getArray () const { return this->array; };
     40    inline const T getEntry(unsigned int number) const;
    4041    /** * @returns The Count of entries in the Array*/
    4142    inline unsigned int getCount()const { return this->entryCount; };
     
    6667Array<T>::Array ()
    6768{
    68   PRINTF(4)("crating new Array\n");
     69  PRINTF(5)("crating new Array\n");
    6970  this->firstEntry = new Entry;
    7071  this->firstEntry->next =NULL;
     
    7273  this->finalized = false;
    7374  this->entryCount = 0; //0 means one entry
     75}
     76
     77template<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];
    7482}
    7583
     
    8189Array<T>::~Array()
    8290{
    83   PRINTF(4)("deleting array\n");
     91  PRINTF(5)("deleting array\n");
    8492  Entry* walker = this->firstEntry;
    8593  Entry* previous;
     
    9199  }
    92100  if (finalized)
    93     delete []this->array;
     101    delete[] this->array;
    94102}
    95103
     
    101109void Array<T>::finalizeArray ()
    102110{
    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);
    107114  Entry* walker = this->firstEntry;
    108115  for (int i=0; i<this->entryCount; i++)
Note: See TracChangeset for help on using the changeset viewer.