Main Page   Namespace List   Class Hierarchy   Compound List   File List   Namespace Members   Compound Members   File Members  

ArrayC< Typ > Class Template Reference

#include <arrayc.h>

Inheritance diagram for ArrayC< Typ >:

Inheritance graph
[legend]
Collaboration diagram for ArrayC< Typ >:

Collaboration graph
[legend]
List of all members.

Public Methods

 ArrayC ()
 ArrayC (const ArrayC< Typ > &A)
 ArrayC (const Typ *data, long datalen)
 ArrayC (long l, long b, const Typ &bl)
 ArrayC (long datalen)
 ~ArrayC ()
const ArrayC< Typ > & operator= (const ArrayC< Typ > &A)
short operator== (const ArrayC< Typ > &a)
short operator!= (const ArrayC< Typ > &a)
const Typ & get (long l) const
long capacity () const
long size () const
Typ & operator[] (long i)
Typ & back ()
short put (long l, const Typ &t)
void set (long l, const Typ &t)
void push_back (const Typ &t)
short pop_back (Typ &t)
short pop_front (Typ &t)
void push ()
void Erase (long a, long e)
Typ * GetBuffer ()
void SetBlockSize (long i)
void SetBuffer (Typ *data, long n)
void SetLength (long l)
short SetBufferLength (long l)
short InsertAtPos (long l, const Typ &t)
void RemoveElementAtPos (long l)
short RemoveElement (Typ &t)
void Empty ()
void OptimizeMemory ()
long GetIndexOf (const Typ &t) const
short Contain (const Typ &t)
long Count (const Typ &t)
void SetBlankAndClear (const Typ &bl)
void SetBlankAndClear (const Typ &bl, long l)

Protected Methods

int MakeLonger (unsigned int b)

Protected Attributes

Typ m_blank
long m_blocklen
long m_buflen
long m_anzahlelemente
Typ * m_array

template<class Typ>
class ArrayC< Typ >


Constructor & Destructor Documentation

template<class Typ>
ArrayC< Typ >::ArrayC   [inline]
 

Definition at line 48 of file arrayc.h.

00048           {
00049     m_buflen= 1;
00050     m_anzahlelemente = 0;
00051     m_blocklen = 0;
00052     m_array = new Typ[1];
00053   }

template<class Typ>
ArrayC< Typ >::ArrayC const ArrayC< Typ > &    A [inline]
 

Definition at line 55 of file arrayc.h.

00055                               {
00056     long i;
00057     m_blocklen=A.m_blocklen;
00058     m_buflen=A.m_buflen;
00059     m_anzahlelemente=A.m_anzahlelemente;
00060     m_array=new Typ[m_buflen];
00061     for(i=0;i<m_buflen;i++){m_array[i]=A.m_array[i];}
00062   }

template<class Typ>
ArrayC< Typ >::ArrayC const Typ *    data,
long    datalen
[inline]
 

Definition at line 64 of file arrayc.h.

00064                                        {
00065     m_buflen= datalen;
00066     m_anzahlelemente = datalen;
00067     m_blocklen = 0;
00068     m_array = new Typ[datalen];
00069     for(long i=0;i<datalen;i++){
00070       m_array[i] = data[i]; 
00071     }
00072   }

template<class Typ>
ArrayC< Typ >::ArrayC long    l,
long    b,
const Typ &    bl
[inline]
 

Definition at line 74 of file arrayc.h.

00074                                       {
00075      m_buflen= l;
00076      m_anzahlelemente = 0;
00077      m_blocklen = b;
00078      m_array = new Typ[l];
00079      SetBlankAndClear(bl);
00080   }

template<class Typ>
ArrayC< Typ >::ArrayC long    datalen [inline]
 

Definition at line 82 of file arrayc.h.

00082                       {
00083     m_buflen= datalen;
00084     m_anzahlelemente = 0;
00085     m_blocklen = 0;
00086     m_array = new Typ[datalen];
00087   }

template<class Typ>
ArrayC< Typ >::~ArrayC   [inline]
 

Definition at line 89 of file arrayc.h.

00089            {
00090     delete [] m_array;
00091   }


Member Function Documentation

template<class Typ>
Typ& ArrayC< Typ >::back   [inline]
 

Definition at line 132 of file arrayc.h.

00132                     {
00133     assert(m_anzahlelemente>0);
00134     return m_array[m_anzahlelemente-1];
00135   }

template<class Typ>
long ArrayC< Typ >::capacity   const [inline]
 

Definition at line 126 of file arrayc.h.

00126 {return m_buflen;}

template<class Typ>
short ArrayC< Typ >::Contain const Typ &    t [inline]
 

Definition at line 269 of file arrayc.h.

00270   {
00271     for(long i=0;i<m_anzahlelemente;i++){
00272       if(m_array[i]==t){return 1;}
00273     }
00274     return 0;
00275   }

template<class Typ>
long ArrayC< Typ >::Count const Typ &    t [inline]
 

Definition at line 278 of file arrayc.h.

00279   {
00280     long j=0;
00281     for(long i=0;i<m_anzahlelemente;i++){
00282       if(m_array[i]==t){j++;}
00283     }
00284     return j;
00285   }

template<class Typ>
void ArrayC< Typ >::Empty   [inline]
 

Definition at line 249 of file arrayc.h.

00249               {
00250     m_anzahlelemente=0;
00251   }

template<class Typ>
void ArrayC< Typ >::Erase long    a,
long    e
[inline]
 

Definition at line 179 of file arrayc.h.

00179                             {
00180     if(a<0){a=0;}
00181     if(e>=m_anzahlelemente){e=m_anzahlelemente-1;}
00182     if(a>e){return;}
00183     long i; 
00184     m_anzahlelemente-=e-a+1;
00185     for(i=a;i<m_anzahlelemente;i++){
00186       m_array[i]=m_array[i+(e-a)+1];
00187     }
00188   }

template<class Typ>
const Typ& ArrayC< Typ >::get long    l const [inline]
 

Definition at line 121 of file arrayc.h.

00121                                {
00122      assert(l<m_anzahlelemente);
00123      return m_array[l];
00124   }

template<class Typ>
Typ* ArrayC< Typ >::GetBuffer   [inline]
 

Definition at line 190 of file arrayc.h.

00190 {return m_array;}

template<class Typ>
long ArrayC< Typ >::GetIndexOf const Typ &    t const [inline]
 

Definition at line 262 of file arrayc.h.

00262                                      { 
00263     for(long i=0;i<m_anzahlelemente;i++){if(m_array[i]==t){return long(i);}}
00264     return -1;
00265   }

template<class Typ>
short ArrayC< Typ >::InsertAtPos long    l,
const Typ &    t
[inline]
 

Definition at line 214 of file arrayc.h.

00214                                         {
00215      long i;
00216      if(l>=m_anzahlelemente) return 0;
00217      if (m_anzahlelemente >= m_buflen){MakeLonger(m_blocklen+1);}
00218      for(i=m_anzahlelemente;i>l;i--){m_array[i]=m_array[i-1];}
00219      m_array[l]=t;  
00220      m_anzahlelemente++;
00221      return 1;
00222   }

template<class Typ>
int ArrayC< Typ >::MakeLonger unsigned int    b [inline, protected]
 

Definition at line 303 of file arrayc.h.

00303                                 {
00304      Typ *Ablage;
00305      long i,lAlt;
00306      Ablage = m_array;
00307      lAlt=m_buflen;
00308      m_buflen+=b;
00309      m_array = new Typ[m_buflen]; assert(m_array);
00310      if(m_array==0) return 0;
00311      for(i=0;i<lAlt;i++){m_array[i]=Ablage[i];}
00312      for(i=lAlt;i<m_buflen;i++){m_array[i]=m_blank;}
00313      delete [] Ablage;
00314      return 1;
00315   }

template<class Typ>
short ArrayC< Typ >::operator!= const ArrayC< Typ > &    a [inline]
 

Definition at line 114 of file arrayc.h.

00114                                           {
00115     for(long i=0;i<m_buflen;i++){
00116       if(m_array[i]!=a.m_array[i]) return 1;
00117     }
00118     return 0;
00119   }

template<class Typ>
const ArrayC<Typ>& ArrayC< Typ >::operator= const ArrayC< Typ > &    A [inline]
 

Definition at line 93 of file arrayc.h.

00093                                                       {
00094     if (this == &A) return *this;
00095     long i;
00096     delete [] m_array;
00097     m_blocklen=A.m_blocklen;
00098     m_buflen=A.m_buflen;
00099     m_anzahlelemente=A.m_anzahlelemente;
00100     m_array=new Typ[m_buflen];
00101     for(i=0;i<m_buflen;i++){m_array[i]=A.m_array[i];}
00102     return *this;
00103   }

template<class Typ>
short ArrayC< Typ >::operator== const ArrayC< Typ > &    a [inline]
 

Definition at line 106 of file arrayc.h.

00106                                           {
00107     for(long i=0;i<m_buflen;i++){
00108       if(m_array[i]!=a.m_array[i]) return 0;
00109     }
00110     return 1;
00111   }

template<class Typ>
Typ& ArrayC< Typ >::operator[] long    i [inline]
 

Definition at line 130 of file arrayc.h.

00130 {return m_array[i];}

template<class Typ>
void ArrayC< Typ >::OptimizeMemory   [inline]
 

Definition at line 253 of file arrayc.h.

00253                        {
00254     long i;
00255     Typ* tmparray=new Typ[m_anzahlelemente];
00256     m_buflen=m_anzahlelemente;
00257     for(i=0;i<m_anzahlelemente;i++){tmparray[i]=m_array[i];}
00258     delete [] m_array;
00259     m_array=tmparray;
00260   }

template<class Typ>
short ArrayC< Typ >::pop_back Typ &    t [inline]
 

Definition at line 153 of file arrayc.h.

00154   {
00155     short erg = m_anzahlelemente>0;
00156     if(m_anzahlelemente>0){
00157       m_anzahlelemente--;
00158       t = m_array[m_anzahlelemente];
00159     }
00160     return erg;
00161   }

template<class Typ>
short ArrayC< Typ >::pop_front Typ &    t [inline]
 

Definition at line 163 of file arrayc.h.

00164   {
00165     short erg = m_anzahlelemente>0;
00166     if(erg){
00167       t = m_array[0];
00168       RemoveElementAtPos(0);
00169     }
00170     return erg;
00171   }

template<class Typ>
void ArrayC< Typ >::push   [inline]
 

Definition at line 173 of file arrayc.h.

00173              {
00174     assert(m_anzahlelemente>0);
00175     if ( m_anzahlelemente >= m_buflen){MakeLonger(m_blocklen+1);}
00176     push_back(m_array[m_anzahlelemente-1]);
00177   }

template<class Typ>
void ArrayC< Typ >::push_back const Typ &    t [inline]
 

Definition at line 148 of file arrayc.h.

00148                               {
00149      if ( m_anzahlelemente >= m_buflen){MakeLonger(m_blocklen+1);}
00150      m_array[m_anzahlelemente++]=t;   
00151   }

template<class Typ>
short ArrayC< Typ >::put long    l,
const Typ &    t
[inline]
 

Definition at line 137 of file arrayc.h.

00137                                 {
00138      if(l>=m_anzahlelemente) return 0;
00139      m_array[l]=t;
00140      return 1;
00141   }

template<class Typ>
short ArrayC< Typ >::RemoveElement Typ &    t [inline]
 

Definition at line 238 of file arrayc.h.

00238                              {
00239     long i; 
00240     for(i=0;i<m_anzahlelemente;i++){
00241       if(m_array[i]==t){
00242         RemoveElementAtPos(i);
00243         return true;
00244       }
00245     }
00246     return false;
00247   }

template<class Typ>
void ArrayC< Typ >::RemoveElementAtPos long    l [inline]
 

Definition at line 225 of file arrayc.h.

00226   {
00227     assert(l<m_buflen);
00228     long i; 
00229     m_anzahlelemente--;
00230     //kein memcpy um, damit das ganze auch für arrays von Klassen funktioniert.
00231     //memcpy(&m_array[i],&m_array[i+1],(m_anzahlelemente-l)*sizeof(Typ));
00232     for(i=l;i<m_anzahlelemente;i++){
00233       m_array[i]=m_array[i+1];
00234     }
00235   }

template<class Typ>
void ArrayC< Typ >::set long    l,
const Typ &    t
[inline]
 

Definition at line 143 of file arrayc.h.

00143                                 {
00144     if(l>=m_anzahlelemente){SetLength(l+1);}
00145     m_array[l] = t;
00146   }

template<class Typ>
void ArrayC< Typ >::SetBlankAndClear const Typ &    bl,
long    l
[inline]
 

Definition at line 294 of file arrayc.h.

00294                                              {
00295     m_blank=bl;
00296     if(l>m_anzahlelemente) m_anzahlelemente=l;
00297     SetBufferLength(l);
00298     long i;
00299     for(i=0;i<m_buflen;i++){m_array[i]=m_blank;}
00300   }

template<class Typ>
void ArrayC< Typ >::SetBlankAndClear const Typ &    bl [inline]
 

Definition at line 287 of file arrayc.h.

00288   {
00289     m_blank=bl;
00290     long i;
00291     for(i=0;i<m_buflen;i++){m_array[i]=m_blank;}
00292   }

template<class Typ>
void ArrayC< Typ >::SetBlockSize long    i [inline]
 

Definition at line 192 of file arrayc.h.

00192 {m_blocklen=i;}

template<class Typ>
void ArrayC< Typ >::SetBuffer Typ *    data,
long    n
[inline]
 

Definition at line 194 of file arrayc.h.

00194                                    { // aufeigene Verantwortung
00195     delete m_array;
00196     m_array = data;
00197     m_anzahlelemente = n;
00198     m_buflen = m_anzahlelemente;
00199   }

template<class Typ>
short ArrayC< Typ >::SetBufferLength long    l [inline]
 

Definition at line 206 of file arrayc.h.

00206                                {
00207     if(l>m_buflen){
00208       return MakeLonger((l-m_buflen)+m_blocklen);
00209     }
00210     return 0;
00211     //  if(l>m_anzahlelemente){m_anzahlelemente=l;}
00212   }

template<class Typ>
void ArrayC< Typ >::SetLength long    l [inline]
 

Definition at line 201 of file arrayc.h.

00201                         {
00202     SetBufferLength(l);
00203     m_anzahlelemente=l;
00204   }

template<class Typ>
long ArrayC< Typ >::size   const [inline]
 

Definition at line 128 of file arrayc.h.

00128 {return m_anzahlelemente;}


Member Data Documentation

template<class Typ>
long ArrayC< Typ >::m_anzahlelemente [protected]
 

Definition at line 44 of file arrayc.h.

Referenced by ArrayC< Value >::ArrayC(), and ArrayC< Value >::operator=().

template<class Typ>
Typ* ArrayC< Typ >::m_array [protected]
 

Definition at line 45 of file arrayc.h.

Referenced by ArrayC< Value >::ArrayC(), ArrayC< Value >::operator!=(), ArrayC< Value >::operator=(), and ArrayC< Value >::operator==().

template<class Typ>
Typ ArrayC< Typ >::m_blank [protected]
 

Definition at line 41 of file arrayc.h.

template<class Typ>
long ArrayC< Typ >::m_blocklen [protected]
 

Definition at line 42 of file arrayc.h.

Referenced by ArrayC< Value >::ArrayC(), and ArrayC< Value >::operator=().

template<class Typ>
long ArrayC< Typ >::m_buflen [protected]
 

Definition at line 43 of file arrayc.h.

Referenced by ArrayC< Value >::ArrayC(), and ArrayC< Value >::operator=().


The documentation for this class was generated from the following file:
Generated on Tue Jul 29 14:26:53 2003 for Open ActiveWrl by doxygen1.3-rc2