1 \ *****************************************************************************
2 \ * Copyright (c) 2004, 2008 IBM Corporation
3 \ * All rights reserved.
4 \ * This program and the accompanying materials
5 \ * are made available under the terms of the BSD License
6 \ * which accompanies this distribution, and is available at
7 \ * http://www.opensource.org/licenses/bsd-license.php
10 \ * IBM Corporation - initial implementation
11 \ ****************************************************************************/
16 0 value hash-collisions
21 : hash-find ( str len head -- 0 | link )
22 >r 2dup 2dup hash ( str len str len hash R: head )
23 dup >r @ dup ( str len str len *hash *hash R: head hash )
24 IF ( str len str len *hash R: head hash )
25 link>name name>string string=ci ( str len true|false R: head hash )
34 nip nip ( str len 0 R: head hash )
37 2drop r> @ r> drop ( *hash R: )
39 from-hash 1+ to from-hash
43 r> r> swap >r ((find)) ( str len head R: hash=0 )
56 : hash-reveal hash off ;
58 ' hash-reveal to (reveal)
62 \ print out all entries in the hash table
63 : dump-hash-table ( -- )
65 hash-table hash-size 0 DO
67 over . s" : " type link>name name>string type cr
73 s" hash-collisions: " type hash-collisions . cr
74 s" from-hash: " type from-hash . cr
75 s" not-from-hash: " type not-from-hash . cr