Main Page   Packages   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members   Search  

AList Class Reference

#include <AList.hpp>

List of all members.

Public Methods

 AList ()
 AList (ULONG size)
virtual ~AList ()
void clear ()
void insert (Elem item)
void append (Elem item)
Elem remove ()
void setFirst ()
void prev ()
void next ()
long getPos ()
void setPos (ULONG pos)
void setValue (Elem item)
Elem currValue () const
ULONG length () const
ULONG getMaxSize () const
bool isEmpty () const
bool isInList () const
long find (Elem val)
void display () const

Private Attributes

ULONG msize
ULONG nbList
ULONG curr
Elemlistarray


Constructor & Destructor Documentation

AList::AList  
 

Definition at line 10 of file AList.cpp.

00011   : msize( LIST_SIZE ), nbList( 0 ), curr( 0 ) 
00012 {
00013   listarray = new Elem[ LIST_SIZE ];
00014 }

AList::AList ULONG    sz
 

Definition at line 16 of file AList.cpp.

00017   : msize( sz ), nbList( 0 ), curr( 0 ) 
00018 {
00019   listarray = new Elem[ sz ];
00020 }

AList::~AList   [virtual]
 

Definition at line 22 of file AList.cpp.

00022                                                      : return array space
00023 {
00024   delete [] listarray;
00025 }


Member Function Documentation

void AList::append Elem    item
 

Definition at line 49 of file AList.cpp.

00050 {
00051   assert( nbList < msize );               // List must not be full
00052   listarray[ nbList ] = item;            
00053   nbList++;                               // Increment list size
00054 }

void AList::clear  
 

Definition at line 27 of file AList.cpp.

00028 {
00029   nbList = 0;                             // Simply reinitialize values
00030   curr = 0;
00031 }

__inline Elem AList::currValue   const
 

Definition at line 120 of file AList.cpp.

00121 {
00122   assert( isInList() );                   // Curr must be at valid position
00123   return listarray[ curr ];               // This is OK ?!?
00124 }

void AList::display   const
 

Definition at line 147 of file AList.cpp.

00148 {
00149   register ULONG i = 0;
00150 
00151   printf( "===========================================\n" );
00152 
00153   for( ; i < nbList; i++ ) {
00154     printf( "%d \n ", listarray[i] );
00155   }
00156 
00157   printf( "===========================================\n" );
00158 }

long AList::find Elem    item
 

Definition at line 136 of file AList.cpp.

00137 {
00138   while( isInList() ) 
00139   {
00140     if ( listarray[ curr ] == item ) return getPos();
00141     next();
00142   }
00143 
00144   return -1;
00145 }

__inline ULONG AList::getMaxSize   const
 

Definition at line 109 of file AList.cpp.

00110 {
00111   return msize;
00112 }

__inline long AList::getPos  
 

Definition at line 97 of file AList.cpp.

Referenced by find().

00098 {
00099   if ( isEmpty() ) return -1;
00100   return curr;
00101 }

void AList::insert Elem    item
 

Definition at line 34 of file AList.cpp.

00035 {
00036   // Array must not be full and curr must be a legal position
00037   assert( nbList < msize );
00038   assert( curr <= nbList );
00039 
00040   for( ULONG i = nbList; i > curr; i-- )  // Shift Elems up to make room
00041   {  
00042     listarray[ i ] = listarray[ i-1 ];
00043   }
00044 
00045   listarray[ curr ] = item;
00046   nbList++;                               // Increment current list size
00047 }

__inline bool AList::isEmpty   const
 

Definition at line 126 of file AList.cpp.

00127 {
00128   return ( nbList == 0  &&  curr == 0 );
00129 }

__inline bool AList::isInList   const
 

Definition at line 131 of file AList.cpp.

00132 {
00133   return ( nbList != 0  &&  curr >= 0  &&  curr < nbList );
00134 }

__inline ULONG AList::length   const
 

Definition at line 104 of file AList.cpp.

00105 {
00106   return nbList;
00107 }

__inline void AList::next  
 

Definition at line 85 of file AList.cpp.

Referenced by find().

00086 {
00087   if ( curr >= msize-1 ) return;
00088   curr++;
00089 }

__inline void AList::prev  
 

Definition at line 79 of file AList.cpp.

00080 {
00081   if ( curr <= 0 ) return;
00082   curr--;
00083 }

Elem AList::remove  
 

Definition at line 56 of file AList.cpp.

00057 {
00058   assert( !isEmpty()  );                  // Must be an Elem to remove
00059   assert( isInList()  );  
00060 
00061   Elem temp = listarray[curr];            // Store removed Elem
00062 
00063   register ULONG i;
00064   for( i = curr; i < nbList-1; i++)       // Shift elements down
00065   {
00066     listarray[ i ] = listarray[ i + 1 ];
00067   }
00068 
00069   nbList--;                               // Decrement current list size
00070 
00071   return temp;  // This is OK ?!? or by copy constructor?
00072 }

__inline void AList::setFirst  
 

Definition at line 74 of file AList.cpp.

00075 {
00076   curr = 0;
00077 }

__inline void AList::setPos ULONG    pos
 

Definition at line 91 of file AList.cpp.

00092 {
00093   if ( pos > msize-1 ) return;            // Position must be valid
00094   curr = pos;
00095 }

__inline void AList::setValue Elem    item
 

Definition at line 114 of file AList.cpp.

00115 {
00116   assert( isInList() );                   // Curr must be at valid position
00117   listarray[ curr ] = item;
00118 }


Member Data Documentation

ULONG AList::curr [private]
 

Definition at line 37 of file AList.hpp.

Elem* AList::listarray [private]
 

Definition at line 38 of file AList.hpp.

ULONG AList::msize [private]
 

Definition at line 35 of file AList.hpp.

ULONG AList::nbList [private]
 

Definition at line 36 of file AList.hpp.


The documentation for this class was generated from the following files:
Generated on Sun Oct 14 18:48:23 2001 for Standard J2K Library by doxygen1.2.11.1 written by Dimitri van Heesch, © 1997-2001