資源簡介
虛擬機的設計與實現CC++(源代碼和書籍)
代碼片段和文件信息
#include
#include
#include
#define?TRUE???1
#define?FALSE??0
/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+?declarations??????????????????????????????????????????????????????+
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
struct?HashTbl
{
unsigned?char?empty; /*indicates?if?entry?is?used?or?not*/
????char?str[32]; /*string?payload*/
????struct?HashTbl?*left;
????struct?HashTbl?*right;
};
#define?PRIME?5
class?HashTable
{
struct?HashTbl?hashTbl[PRIME]; /*the?hash?table?itself*/
int?hashpjw(char?*s);?
/*binary?tree?routines?needed?for?collision?resoltuion*/
struct?HashTbl*?findNode(struct?HashTbl*?link?char?*val);
void?insertNode(struct?HashTbl**?link?char?*val);
void?printTree(struct?HashTbl*?link?int?level);
void?deleteAll(struct?HashTbl?**link);
public:
HashTable();
~HashTable();
struct?HashTbl*?queryHashTbl(char?*str);
void?addHashTblEntry(char?*val);
void?printHashTbl();
};
/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+?definitions???????????????????????????????????????????????????????+
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
HashTable::HashTable()
{
int?i;
for(i=0;i {?
hashTbl[i].empty?=?TRUE;
hashTbl[i].str[0]=‘\0‘;
}
return;
}/*end?constructor*/
/*-----------------------------------------------------------------*/
HashTable::~HashTable()
{
int?i;
for(i=0;i {?
deleteAll(&(hashTbl[i].left));
deleteAll(&(hashTbl[i].right));
}
return;
}/*end?destructor*/
/*-----------------------------------------------------------------*/
/*
if?symbol?exists?in?hash?table?we?get?a?pointer?to?the?node
if?a?symbol?does?not?exist?in?the?hash?table?we?get?NULL
*/
struct?HashTbl*?HashTable::queryHashTbl(char?*str)
{
int?hash;
hash?=?hashpjw(str);
if(hashTbl[hash].empty==TRUE)
{?
return(NULL);?
}
return(findNode(&(hashTbl[hash])?str));
}/*end?queryHashTbl*/
/*-----------------------------------------------------------------*/
void?HashTable::addHashTblEntry(char?*val)
{
struct?HashTbl?*ptr;
int?hash;
hash?=?hashpjw(val);
printf(“HashTable.addHashTblEntry():?hash(%s)=%d\n“valhash);
if(hashTbl[hash].empty==TRUE)
{?
hashTbl[hash].empty=FALSE;
strcpy(hashTbl[hash].strval);
hashTbl[hash].left?=?NULL;
hashTbl[hash].right?=?NULL;
return;?
}
ptr?=?&hashTbl[hash];
insertNode(&ptr?val);
return;
}/*end?addHashTblEntry*/
/*-----------------------------------------------------------------*/
void?HashTable::printHashTbl()
{
int?i;
for(i=0;i {?
if(hashTbl[i].empty?==?FALSE)
{
printf(“--Hash?Slot?(%d)--\n“i);
printTree(&(hashTbl[i])?0);
printf(“\n“);
}
}
printf(“\n“);
return;
}/*end?printHashTbl*/
/*-----------------------------------------------------
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件??????15824??2001-05-05?10:42??虛擬機的設計與實現CC++(源代碼和書籍)\源碼\linux\bin\filedmp
?????文件??????92938??2001-05-05?10:42??虛擬機的設計與實現CC++(源代碼和書籍)\源碼\linux\bin\hashtbl
?????文件?????181308??2001-05-05?10:42??虛擬機的設計與實現CC++(源代碼和書籍)\源碼\linux\bin\hasm
?????文件?????114414??2001-05-05?10:42??虛擬機的設計與實現CC++(源代碼和書籍)\源碼\linux\bin\hecvm
?????文件??????90869??2001-05-05?10:42??虛擬機的設計與實現CC++(源代碼和書籍)\源碼\linux\bin\list
?????文件???????7289??2001-05-05?10:42??虛擬機的設計與實現CC++(源代碼和書籍)\源碼\linux\bin\numfmt
?????文件??????16306??2001-05-05?10:42??虛擬機的設計與實現CC++(源代碼和書籍)\源碼\linux\bin\rawbin
?????文件???????7702??2001-05-05?10:42??虛擬機的設計與實現CC++(源代碼和書籍)\源碼\linux\bin\tree
?????文件????????952??2001-05-05?10:41??虛擬機的設計與實現CC++(源代碼和書籍)\源碼\linux\bldall.sh
?????文件???????6945??2001-05-05?10:41??虛擬機的設計與實現CC++(源代碼和書籍)\源碼\linux\dstruct\hashtbl\hashtbl.cpp
?????文件?????????42??2001-05-05?10:41??虛擬機的設計與實現CC++(源代碼和書籍)\源碼\linux\dstruct\hashtbl\makefile
?????文件???????2696??2001-05-05?10:41??虛擬機的設計與實現CC++(源代碼和書籍)\源碼\linux\dstruct\list\list.cpp
?????文件?????????33??2001-05-05?10:41??虛擬機的設計與實現CC++(源代碼和書籍)\源碼\linux\dstruct\list\makefile
?????文件?????????33??2001-05-05?10:41??虛擬機的設計與實現CC++(源代碼和書籍)\源碼\linux\dstruct\tree\makefile
?????文件???????6094??2001-05-05?10:41??虛擬機的設計與實現CC++(源代碼和書籍)\源碼\linux\dstruct\tree\tree.cpp
?????文件???????9081??2001-05-05?10:41??虛擬機的設計與實現CC++(源代碼和書籍)\源碼\linux\hasm\bldfile.cpp
?????文件???????8096??2001-05-05?10:41??虛擬機的設計與實現CC++(源代碼和書籍)\源碼\linux\hasm\cmdline.cpp
?????文件????????536??2001-05-05?10:41??虛擬機的設計與實現CC++(源代碼和書籍)\源碼\linux\hasm\common.c
?????文件???????1379??2001-05-05?10:41??虛擬機的設計與實現CC++(源代碼和書籍)\源碼\linux\hasm\error.c
?????文件???????7621??2001-05-05?10:41??虛擬機的設計與實現CC++(源代碼和書籍)\源碼\linux\hasm\exenv.c
?????文件???????1339??2001-05-05?10:41??虛擬機的設計與實現CC++(源代碼和書籍)\源碼\linux\hasm\globvar.cpp
?????文件???????9635??2001-05-05?10:41??虛擬機的設計與實現CC++(源代碼和書籍)\源碼\linux\hasm\hashtbl.cpp
?????文件???????2793??2001-05-05?10:41??虛擬機的設計與實現CC++(源代碼和書籍)\源碼\linux\hasm\iset.c
?????文件????????755??2001-05-05?10:41??虛擬機的設計與實現CC++(源代碼和書籍)\源碼\linux\hasm\label.cpp
?????文件??????22823??2001-05-05?10:41??虛擬機的設計與實現CC++(源代碼和書籍)\源碼\linux\hasm\linetok.cpp
?????文件??????11493??2001-05-05?10:41??虛擬機的設計與實現CC++(源代碼和書籍)\源碼\linux\hasm\linux.c
?????文件???????7454??2001-05-05?10:41??虛擬機的設計與實現CC++(源代碼和書籍)\源碼\linux\hasm\lnscan.cpp
?????文件???????4538??2001-05-05?10:41??虛擬機的設計與實現CC++(源代碼和書籍)\源碼\linux\hasm\main.cpp
?????文件?????????50??2001-05-05?10:41??虛擬機的設計與實現CC++(源代碼和書籍)\源碼\linux\hasm\makefile
?????文件??????23385??2001-05-05?10:41??虛擬機的設計與實現CC++(源代碼和書籍)\源碼\linux\hasm\pass1.cpp
............此處省略202個文件信息
- 上一篇:C++ Primer第5版頂級清晰文字版
- 下一篇:c程序設計第四版pdf
評論
共有 條評論