This is the mail archive of the
kawa@sources.redhat.com
mailing list for the Kawa project.
Re: home-directory in .kawarc.scm; kawa.init for SLIB; hash tables
- To: "Nic Ferrier" <nferrier at tapsellferrier dot co dot uk>
- Subject: Re: home-directory in .kawarc.scm; kawa.init for SLIB; hash tables
- From: brlewis at alum dot mit dot edu
- Date: 23 Mar 2001 08:37:45 -0500
- Cc: per at bothner dot com, dougo at ccs dot neu dot edu, kawa at sourceware dot cygnus dot com
- References: <sabb21f1.057@tapsellferrier.co.uk>
"Nic Ferrier" <nferrier@tapsellferrier.co.uk> writes:
> BRL has a Hash interface as I recall...
Yes. It uses the Java 1.1 Hashtable class for now. When Kawa depends
on newer classes I may change it.
;
; Generic hash table interface
;
(define (brl-hash)
(make <java.util.Hashtable>))
(define (brl-hash? obj)
(instance? obj <java.util.Dictionary>))
(define (brl-hash-size hh :: <java.util.Dictionary>)
(make <integer> (invoke hh 'size)))
(define (brl-hash-put! hh :: <java.util.Dictionary> key val)
(invoke hh 'put key val))
(define (brl-hash-get hh :: <java.util.Dictionary> key)
(let ((result (invoke hh 'get key)))
(if (eq? #!null result)
#f ; as assoc does
result)))
(define (brl-hash-remove! hh :: <java.util.Dictionary> key)
(invoke hh 'remove key))
(define (brl-hash-keys hh :: <java.util.Dictionary>)
(letrec ((enum (lambda (ee :: <java.util.Enumeration>)
(if (invoke ee 'hasMoreElements)
(let ((nxt (invoke ee 'nextElement)))
(cons nxt (enum ee)))
'()))))
(enum (invoke hh 'keys))))
(define (brl-hash-contains-key? hh :: <java.util.Hashtable> key)
(invoke hh 'containsKey key))
--
Bruce R. Lewis http://brl.sourceforge.net/