⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 dictionr.cpp

📁 不错的国外的有限元程序代码,附带详细的manual,可以节省很多的底层工作.
💻 CPP
字号:
//   file DICTIONR.CXX
 
#include "dictionr.hxx"
#include "debug.def"
#include <stdlib.h>


Dictionary :: ~Dictionary ()
   // Destructor.
{
   Pair* Next ;

   while (first) {
      Next = first -> giveNext() ;
      delete first ;
      first = Next ;}
}


Pair*  Dictionary :: add (char k, double v)
   // Adds the pair (k,v) to the receiver. Returns this new pair.
{
   Pair* newPair ;

#  ifdef DEBUG
      if (this->includes(k))  {
	 printf ("Error in Dictionary::add(%c)",k," - key already exists\n");
	 exit(0) ;}
#  endif

   newPair = new Pair(k,v) ;
   if (last)
      last -> append(newPair) ;
   else                                   // empty dictionary
      first = newPair ;
   last = newPair ;

   return newPair ;
}


double&  Dictionary :: at (char aKey)
   // Returns the value of the pair which key is aKey. If such pair does
   // not exist, creates it and assign value 0.
{
   Pair *next,*newPair ;

   next = first ;
   while (next) {
      if (next->giveKey() == aKey)
	 return next->giveValue() ;
      next = next->giveNext() ;}

   newPair = this->add(aKey,0) ;          // pair does not exist yet
   return newPair->giveValue() ;
}


int  Dictionary :: includes (char aKey)
   // Returns True if the receiver contains a pair which key is aKey, else
   // returns False.
{
   Pair* next ;

   next = first ;
   while (next) {
      if (next->giveKey() == aKey)
	 return TRUE ;
      next = next->giveNext() ;}

   return FALSE ;
}


void  Dictionary :: printYourself ()
   // Prints the receiver on screen.
{
   Pair* next ;

   printf ("Dictionary : \n") ;

   next = first ;
   while (next) {
      next -> printYourself() ;
      next = next -> giveNext() ;}
}


⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -