diff options
author | Thomas Grill <xovo@users.sourceforge.net> | 2004-02-23 03:32:54 +0000 |
---|---|---|
committer | Thomas Grill <xovo@users.sourceforge.net> | 2004-02-23 03:32:54 +0000 |
commit | d5f3af34344340c718d07c9c84d562785443747e (patch) | |
tree | 87ca39a07f491898c292c2900a6bd3aee8134f77 /externals/grill/pool/source | |
parent | 95bf21f70657b8acada4120e51207d64c97445cd (diff) |
""
svn path=/trunk/; revision=1350
Diffstat (limited to 'externals/grill/pool/source')
-rw-r--r-- | externals/grill/pool/source/pool.cpp | 17 | ||||
-rw-r--r-- | externals/grill/pool/source/pool.h | 3 |
2 files changed, 18 insertions, 2 deletions
diff --git a/externals/grill/pool/source/pool.cpp b/externals/grill/pool/source/pool.cpp index 4d6d100e..dcb16237 100644 --- a/externals/grill/pool/source/pool.cpp +++ b/externals/grill/pool/source/pool.cpp @@ -878,6 +878,19 @@ BL pooldir::SvDirXML(ostream &os,I depth,const AtomList &dir,I ind) return true; } +unsigned int pooldir::FoldBits(unsigned long h,int bits) +{ + if(!bits) return 0; + const int hmax = (1<<bits)-1; + unsigned int ret = 0; + for(unsigned int i = 0; i < sizeof(h)*8; i += bits) + ret ^= (h>>i)&hmax; + return ret; +} - - +int pooldir::Int2Bits(unsigned long n) +{ + int b; + for(b = 0; n; ++b) n >>= 1; + return b; +} diff --git a/externals/grill/pool/source/pool.h b/externals/grill/pool/source/pool.h index 99e271b3..1874d334 100644 --- a/externals/grill/pool/source/pool.h +++ b/externals/grill/pool/source/pool.h @@ -103,6 +103,9 @@ protected: pooldir *parent; const I vbits,dbits,vsize,dsize; + static unsigned int FoldBits(unsigned long h,int bits); + static int Int2Bits(unsigned long n); + struct valentry { int cnt; poolval *v; }; struct direntry { int cnt; pooldir *d; }; |