Chinaunix首页 | 论坛 | 博客
  • 博客访问: 510123
  • 博文数量: 91
  • 博客积分: 9223
  • 博客等级: 中将
  • 技术积分: 1777
  • 用 户 组: 普通用户
  • 注册时间: 2007-04-02 17:37
个人简介

!!!!!!!!!!!!

文章分类

全部博文(91)

文章存档

2013年(3)

2012年(4)

2011年(37)

2010年(36)

2009年(9)

2008年(2)

分类: LINUX

2011-05-04 20:42:08

sym.csymbol hash table

typedef struct {                                         /* Symbol table descriptor */

       int           inuse;                                         /* Is this entry in use */

       int           hash_size;                                   /* Size of the table below */

       sym_t     **hash_table;                       /* Allocated at run time */

} sym_tabent_t;

 

 

typedef struct sym_t {

       struct sym_t   *forw;                                /* Pointer to next hash list */

       value_t                  name;                                  /* Name of symbol */

       value_t                  content;                        /* Value of symbol */

       int                         arg;                              /* Parameter value */

} sym_t;

 

sym_tabent_t结构表示一个hash表,hash_table[n]指向hash表中的分支n,每个分支n有结构体sym_t表示,每个分支中,有多个sym_t组成,它们组成了一个单向链表,每个sym_t代表一个名、值对。

-----------------------------------------------------------------------------------------------------------------

int symSubOpen()

功能:打开symbol table,初始化。

说明:

-----------------------------------------------------------------------------------------------------------------

 

void symSubClose()

功能:关闭sysbol table

说明:

-----------------------------------------------------------------------------------------------------------------

 

sym_fd_t symOpen(int hash_size)

功能:创建一个 sysbol table

说明:

-----------------------------------------------------------------------------------------------------------------

 

void symClose(sym_fd_t sd)

功能:关闭sysbol table,释放分配的内存。

说明:

-----------------------------------------------------------------------------------------------------------------

 

sym_t* symFirst(sym_fd_t sd)

功能:找到指定sdhash table中第一个symbol

说明:

-----------------------------------------------------------------------------------------------------------------

 

sym_t* symNext(sym_fd_t sd)

功能:找到下一个symbol

说明:

-----------------------------------------------------------------------------------------------------------------

 

sym_t *symLookup(sym_fd_t sd, char_t *name)

功能:在sd hash table中找到名字为namehash

说明:

-----------------------------------------------------------------------------------------------------------------

 

sym_t *symEnter(sym_fd_t sd, char_t *name, value_t v, int arg)

功能:进入hash表中,更新值

说明:

-----------------------------------------------------------------------------------------------------------------

 

int symDelete(sym_fd_t sd, char_t *name)

功能:删除hash表中对应的值。

说明:

-----------------------------------------------------------------------------------------------------------------

 

static sym_t *hash(sym_tabent_t *tp, char_t *name)

功能:根据name找到hash表中对应的值

说明:

-----------------------------------------------------------------------------------------------------------------

 

static int hashIndex(sym_tabent_t *tp, char_t *name)

功能:计算hash索引。一种计算方法而已!

说明:

-----------------------------------------------------------------------------------------------------------------

 

static int isPrime(int n)

功能:核实n是否是素数

说明:

-----------------------------------------------------------------------------------------------------------------

 

static int calcPrime(int size)

功能:找到小于size的最大的素数

说明:

-----------------------------------------------------------------------------------------------------------------

阅读(1425) | 评论(0) | 转发(2) |
给主人留下些什么吧!~~