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

GridC< Typ > Class Template Reference

#include <arrayc.h>

Collaboration diagram for GridC< Typ >:

Collaboration graph
[legend]
List of all members.

Public Methods

 GridC ()
 GridC (long l, long b, long r, long t, const Typ &bl)
 ~GridC ()
const Typ & get (long i, long j) const
void set (long n, long m, const Typ &t)
void SetBlankAndClear (const Typ &bl)

Protected Attributes

Typ m_blank
long m_left
long m_bottom
long m_right
long m_top
long m_width
long m_height
Typ ** m_array
short m_bFirstSet

template<class Typ>
class GridC< Typ >


Constructor & Destructor Documentation

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

Definition at line 324 of file arrayc.h.

References GridC< Typ >::m_array, GridC< Typ >::m_blank, GridC< Typ >::m_bottom, GridC< Typ >::m_height, GridC< Typ >::m_left, GridC< Typ >::m_right, GridC< Typ >::m_top, and GridC< Typ >::m_width.

00325   {
00326      int i,j;
00327      m_left=0;
00328      m_right=0;
00329      m_top=0;
00330      m_bottom=0;
00331      m_width=1;
00332      m_height=1;
00333      m_array=new Typ* [m_width];
00334      for(i=0;i<m_width;i++){
00335         m_array[i]=new Typ[m_height];
00336         for(j=0;j<m_height;j++){m_array[i][j]=m_blank;}
00337      }
00338   }

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

Definition at line 341 of file arrayc.h.

References GridC< Typ >::m_array, GridC< Typ >::m_blank, GridC< Typ >::m_bottom, GridC< Typ >::m_height, GridC< Typ >::m_left, GridC< Typ >::m_right, GridC< Typ >::m_top, and GridC< Typ >::m_width.

00342   {
00343      int i,j;
00344      m_left=l;
00345      m_right=r;
00346      m_top=t;
00347      m_bottom=b;
00348      m_width=r-l+1;assert(m_width>0);
00349      m_height=t-b+1;assert(m_height>0);
00350      m_blank=bl;
00351      m_array=new Typ* [m_width];
00352      for(i=0;i<m_width;i++){
00353         m_array[i]=new Typ[m_height];
00354         for(j=0;j<m_height;j++){m_array[i][j]=m_blank;}
00355      }
00356   }

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

Definition at line 358 of file arrayc.h.

References GridC< Typ >::m_array, and GridC< Typ >::m_width.

00358           {
00359      int i;
00360      for(i=0;i<m_width;i++){delete [] m_array[i];}
00361      delete m_array;
00362   }


Member Function Documentation

template<class Typ>
const Typ& GridC< Typ >::get long    i,
long    j
const [inline]
 

Definition at line 365 of file arrayc.h.

References GridC< Typ >::m_array, GridC< Typ >::m_blank, GridC< Typ >::m_bottom, GridC< Typ >::m_left, GridC< Typ >::m_right, and GridC< Typ >::m_top.

00365                                      {
00366      if((i>m_right)||(i<m_left)||(j>m_top)||(j<m_bottom)) return m_blank; 
00367      return m_array[i-m_left][j-m_bottom];
00368   }

template<class Typ>
void GridC< Typ >::set long    n,
long    m,
const Typ &    t
[inline]
 

Definition at line 371 of file arrayc.h.

References GridC< Typ >::m_array, GridC< Typ >::m_blank, GridC< Typ >::m_bottom, GridC< Typ >::m_height, GridC< Typ >::m_left, GridC< Typ >::m_right, GridC< Typ >::m_top, and GridC< Typ >::m_width.

00371                                       {
00372     int i,j;
00373     if( ((n<m_left)||(n>m_right))&&(m<=m_top)&&(m>=m_bottom) ){
00374       Typ **ablage;
00375       long leftOld=m_left;
00376       //long rightOld=m_right;
00377       long widthOld=m_width;
00378       long s1,s2;
00379       ablage=m_array;
00380       if(n<m_left){m_left=n;s1=leftOld-n;s2=widthOld;}else{m_right=n;s1=0;s2=0;}
00381       m_width=m_right-m_left+1;
00382       m_array = new Typ* [m_width]; 
00383       for(i=0;i<widthOld;i++){m_array[i+s1]=ablage[i];}
00384       for(i=widthOld;i<m_width;i++){
00385         m_array[i]=new Typ[m_height];
00386         for(j=0;j<m_height;j++){m_array[i-s2][j]=m_blank;}
00387       }  
00388       delete ablage;
00389     }else{
00390       if( ((m>m_top)||(m<m_bottom))&&(n>=m_left)&&(n<=m_right) ){
00391       long heightOld=m_height;
00392       //long topOld=m_top;
00393       long bottomOld=m_bottom;
00394       long s1,s2;
00395       if(m<m_bottom){m_bottom=m;s1=bottomOld-m;s2=heightOld;}else{m_top=m;s1=0;s2=0;}
00396       m_height=m_top-m_bottom+1;
00397       for(i=0;i<m_width;i++){
00398         Typ *ablage;
00399         ablage=m_array[i];
00400         m_array[i]= new Typ[m_height];
00401         for(j=0;j<heightOld;j++){m_array[i][j+s1]=ablage[j];}
00402         for(j=heightOld;j<m_height;j++){m_array[i][j-s2]=m_blank;}
00403         delete [] ablage;
00404       }
00405     }else{
00406       if((m>m_top)||(m<m_bottom)||(n<m_left)||(n>m_right)){
00407       long leftOld=m_left;
00408       long bottomOld=m_bottom;
00409       long widthOld=m_width;
00410       long heightOld=m_height;
00411       Typ **ablage;
00412       ablage=m_array;
00413       if(m>m_top){m_top=m;}
00414       if(m<m_bottom){m_bottom=m;}
00415       if(n<m_left){m_left=n;}
00416       if(n>m_right){m_right=n;}
00417       m_width=m_right-m_left+1;
00418       m_height=m_top-m_bottom+1;
00419       m_array = new Typ* [m_width];
00420       for(i=0;i<m_width;i++){
00421         m_array[i]=new Typ[m_height];
00422         for(j=0;j<m_height;j++){m_array[i][j]=m_blank;}
00423       }
00424       for(i=0;i<widthOld;i++){
00425         for(j=0;j<heightOld;j++){
00426           m_array[i+leftOld-m_left][j+bottomOld-m_bottom]=ablage[i][j];
00427         }
00428       }
00429       for(i=0;i<widthOld;i++){delete [] ablage[i];}
00430       delete ablage;
00431     }}}
00432      m_array[n-m_left][m-m_bottom]=t;
00433   }

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

Definition at line 435 of file arrayc.h.

References GridC< Typ >::m_array, GridC< Typ >::m_blank, GridC< Typ >::m_height, and GridC< Typ >::m_width.

00435                                       {
00436      int i,j;
00437      m_blank=bl;
00438      for(i=0;i<m_width;i++){
00439         for(j=0;j<m_height;j++){m_array[i][j]=m_blank;}
00440      }
00441   }


Member Data Documentation

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

Definition at line 447 of file arrayc.h.

Referenced by GridC< Typ >::get(), GridC< Typ >::GridC(), GridC< Typ >::set(), GridC< Typ >::SetBlankAndClear(), and GridC< Typ >::~GridC().

template<class Typ>
short GridC< Typ >::m_bFirstSet [protected]
 

Definition at line 448 of file arrayc.h.

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

Definition at line 444 of file arrayc.h.

Referenced by GridC< Typ >::get(), GridC< Typ >::GridC(), GridC< Typ >::set(), and GridC< Typ >::SetBlankAndClear().

template<class Typ>
long GridC< Typ >::m_bottom [protected]
 

Definition at line 445 of file arrayc.h.

Referenced by GridC< Typ >::get(), GridC< Typ >::GridC(), and GridC< Typ >::set().

template<class Typ>
long GridC< Typ >::m_height [protected]
 

Definition at line 446 of file arrayc.h.

Referenced by GridC< Typ >::GridC(), GridC< Typ >::set(), and GridC< Typ >::SetBlankAndClear().

template<class Typ>
long GridC< Typ >::m_left [protected]
 

Definition at line 445 of file arrayc.h.

Referenced by GridC< Typ >::get(), GridC< Typ >::GridC(), and GridC< Typ >::set().

template<class Typ>
long GridC< Typ >::m_right [protected]
 

Definition at line 445 of file arrayc.h.

Referenced by GridC< Typ >::get(), GridC< Typ >::GridC(), and GridC< Typ >::set().

template<class Typ>
long GridC< Typ >::m_top [protected]
 

Definition at line 445 of file arrayc.h.

Referenced by GridC< Typ >::get(), GridC< Typ >::GridC(), and GridC< Typ >::set().

template<class Typ>
long GridC< Typ >::m_width [protected]
 

Definition at line 446 of file arrayc.h.

Referenced by GridC< Typ >::GridC(), GridC< Typ >::set(), GridC< Typ >::SetBlankAndClear(), and GridC< Typ >::~GridC().


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