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

LabelDict Class Reference

#include <LabelDict.hpp>

List of all members.

Public Methods

void Init ()
void Reset ()
void PrintLabel (TLabelID labelid)
void Print ()


Member Function Documentation

void LabelDict::Init   [inline]
 

Definition at line 153 of file LabelDict.hpp.

00154    {
00155 #ifdef PROFILE
00156       lookupcount=
00157       hashitercount=0;
00158 #endif
00159 
00160       labelnum=0;
00161 
00162 #ifdef XMILL
00163       // No labels
00164       labels=NULL;
00165       labelref=&labels;
00166 
00167       // no saved labels until now
00168       savedlabelnum=0;
00169       savedlabelref=&labels;
00170 
00171       // let's get some memory for the hash table
00172 //      mainmem.WordAlign();
00173 //      hashtable=(CompressLabelDictItem **)mainmem.GetByteBlock(sizeof(CompressLabelDictItem *)*HASHTABLE_SIZE);
00174       hashtable=(CompressLabelDictItem **)new char[sizeof(CompressLabelDictItem *)*HASHTABLE_SIZE];
00175       if(hashtable==NULL)
00176          ExitNoMem();
00177 
00178       for(int i=0;i<HASHTABLE_SIZE;i++)
00179          hashtable[i]=NULL;
00180 #endif
00181 #ifdef XDEMILL
00182       // No labels until now
00183       labeldictlist=NULL;
00184       lastlabeldict=NULL;
00185 #endif
00186    }

void LabelDict::Print   [inline]
 

Definition at line 527 of file LabelDict.hpp.

00529    {
00530       for(unsigned long i=0;i<labelnum;i++)
00531       {
00532          printf("%lu : ",i);
00533          PrintLabel((TLabelID)i);
00534          printf("\n");
00535       }
00536    }

void LabelDict::PrintLabel TLabelID    labelid [inline]
 

Definition at line 502 of file LabelDict.hpp.

00504    {
00505       char           *ptr;
00506       unsigned long  len;
00507       unsigned char  isattrib=ISATTRIB(labelid);
00508 
00509       labelid=(labelid&(ATTRIBLABEL_STARTIDX-1));
00510 
00511 #ifdef XMILL
00512       len=LookupCompressLabel(labelid,&ptr);
00513 #endif
00514 #ifdef XDEMILL
00515       len=LookupLabel(labelid,&ptr,&isattrib);
00516 #endif
00517 
00518       if(isattrib)   // Attribute names start with '@'
00519       {
00520          printf("@");
00521          fwrite(ptr,len,1,stdout);
00522       }
00523       else
00524          fwrite(ptr,len,1,stdout);
00525    }

void LabelDict::Reset   [inline]
 

Definition at line 188 of file LabelDict.hpp.

00189    {  
00190 #ifdef XMILL
00191       int      i;
00192       TLabelID labelid;
00193       CompressLabelDictItem **hashtableref;
00194 
00195       // First, let's scan over the hash table to remove all
00196       // entris of not predefined labels
00197       for(i=0;i<HASHTABLE_SIZE;i++)
00198       {
00199          hashtableref=hashtable+i;
00200          while(*hashtableref!=NULL)
00201          {
00202             if((*hashtableref)->labelid>=predefinedlabelnum)
00203                // Not a predefined label ID?
00204                // ==> Delete
00205                *hashtableref=(*hashtableref)->nextsamehash;
00206             else
00207                // Otherwise, we go to the next label
00208                hashtableref=&((*hashtableref)->nextsamehash);
00209          }
00210       }
00211 
00212       // Now we need to cut the global list of labels.
00213       // We keep the first 'predefinedlabelnum' predefined labels.
00214       CompressLabelDictItem **curlabelref=&labels;
00215 
00216       for(labelid=0;labelid<predefinedlabelnum;labelid++)
00217          curlabelref=&((*curlabelref)->next);
00218 
00219       *curlabelref=NULL;
00220 
00221       labelref=curlabelref;
00222       labelnum=predefinedlabelnum;
00223 
00224       // no saved labels until now
00225       savedlabelnum=0;
00226       savedlabelref=&labels;
00227 #endif
00228 #ifdef XDEMILL
00229       // No labels until now
00230       labelnum=0;
00231       labeldictlist=NULL;
00232       lastlabeldict=NULL;
00233 #endif
00234    }


The documentation for this class was generated from the following file:
Generated on Sat Oct 13 16:08:54 2001 for XMILL by doxygen1.2.11.1 written by Dimitri van Heesch, © 1997-2001