|
From: Andre R. <and...@us...> - 2004-11-20 18:59:59
|
Update of /cvsroot/frontierkernel/Frontier/Common/source In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv32256/Common/source Modified Files: Tag: New_Tables_Experiment-branch langexternal.c Log Message: Added kernel implementation of Frontier.hashTableStats verb. Index: langexternal.c =================================================================== RCS file: /cvsroot/frontierkernel/Frontier/Common/source/langexternal.c,v retrieving revision 1.3.2.2 retrieving revision 1.3.2.3 diff -C2 -d -r1.3.2.2 -r1.3.2.3 *** langexternal.c 15 Nov 2004 20:52:24 -0000 1.3.2.2 --- langexternal.c 20 Nov 2004 18:59:48 -0000 1.3.2.3 *************** *** 56,59 **** --- 56,60 ---- #include "menuverbs.h" /*7.0b6 PBS*/ #include "op.h" /*7.0b6 PBS*/ + #include "ops.h" /*2004-11-19 aradke*/ *************** *** 1700,1703 **** --- 1701,1833 ---- + boolean hashtablestatsverb (hdlhashtable ht, tyvaluerecord *v) { + + handlestream s; + hdlhashnode hn; + bigstring bs, bsnum, bsbucket, bsnode; + //bigstring bspath; + long i, n, ctnodes, ctitems; + short ctpad; + + assert (ht != nil); + + openhandlestream (nil, &s); + + /*number of buckets*/ + + copystring ("\x0E" "hash buckets: ", bs); + + pushlong (gethashbucketcount (ht), bs); + + pushchar (chreturn, bs); + + if (!writehandlestreamstring (&s, bs)) + goto exit; + + /*number of nodes*/ + + copystring ("\x0C" "hash nodes: ", bs); + + hashcountitems (ht, &ctitems); + + pushlong (ctitems, bs); + + pushchar (chreturn, bs); + pushchar (chreturn, bs); + + if (!writehandlestreamstring (&s, bs)) + goto exit; + + /*order of magnitude of buckets for padding indices*/ + + for (ctpad = 0, n = gethashbucketcount (ht); n != 0; ctpad++, n /= 10) + ; + + /*visit all buckets*/ + + for (i = 0; i < gethashbucketcount (ht); i++) { + + copystring ("\x07" "bucket ", bsbucket); + + /*bucket number*/ + + numbertostring (i, bsnum); + + padwithzeros (bsnum, ctpad); + + pushstring (bsnum, bsbucket); + + pushstring (STR_Colon_Space, bsbucket); + + /*nodes in bucket*/ + + for (ctnodes = 0, hn = nthhashbucket (ht, i); hn != nil; hn = (**hn).hashlink) + ctnodes++; + + pushlong (ctnodes, bsbucket); + + if (ctnodes == 1) + pushstring ("\x05" " node", bsbucket); + else + pushstring ("\x06" " nodes", bsbucket); + + pushchar (chreturn, bsbucket); + + if (!writehandlestreamstring (&s, bsbucket)) + goto exit; + + /*visit nodes in bucket*/ + + for (hn = nthhashbucket (ht, i); hn != nil; hn = (**hn).hashlink) { + + setemptystring (bsnode); + + pushchar (chtab, bsnode); /*indent*/ + + /*type of value*/ + + ostypetostring (langgettypeid (langgettype ((**hn).val)), bs); + + pushstring (bs, bsnode); + + /*memory address of node handle*/ + + numbertohexstring ((long) hn, bs); + + pushstring (bs, bsnode); + + pushchar (chspace, bsnode); + + pushstring ("\x02" " \"", bsnode); + + if (!writehandlestreamstring (&s, bsnode)) + goto exit; + + /*hash key*/ + + gethashkey (hn, bs); + + if (!writehandlestreamstring (&s, bs)) + goto exit; + + copystring ("\x01" "\"", bs); + + pushchar (chreturn, bs); + + if (!writehandlestreamstring (&s, bs)) + goto exit; + }/*for*/ + + } /*for*/ + + return (setheapvalue (closehandlestream (&s), stringvaluetype, v)); + + exit: + + disposehandlestream (&s); + + return (false); + } /*hashtablestatsverb*/ + static boolean getfullpath (hdlhashtable htable, bigstring bsname, boolean flquote, bigstring bspath, hdlwindowinfo *hroot) { |